Can I just use 1 cmdlet without installation of the POSH?

Dec 14, 2007 at 8:22 PM
Hi,

I just need to use Get-Hash and may be couple of others from the whole package. Is it possible without installation of full blown POSH just get those cmdlets and deploy with my script?
Second question. How do I change back my command prompt to default prompt after installation of POSH?

Thanks,
G
Dec 14, 2007 at 10:09 PM
as an alternative:
function Get-MD5(System.IO.FileInfo $file = $(throw 'Usage: Get-MD5 System.IO.FileInfo')) {
$stream = $null;
$cryptoServiceProvider = System.Security.Cryptography.MD5CryptoServiceProvider
$hashAlgorithm = new-object $cryptoServiceProvider
$stream = $file.OpenRead();
$hashByteArray = $hashAlgorithm.ComputeHash($stream);
$stream.Close();
array $hash = @()
foreach ($byte in $hashByteArray) {
$hash += $byte.ToString("X2")
}
$hashstring = string::join(" ", $hash)

## We have to be sure that we close the file stream if any exceptions are thrown.
trap {
if ($stream -ne $null) {
$stream.Close();
}
break;
}
return $hashstring;
}
Dec 15, 2007 at 12:30 AM
Wow, thanks, that's all that's it to it?
Will this work on files ~100MB in size or native PCSX cmdlet is better for this implementation?
Coordinator
Dec 15, 2007 at 6:02 PM


artisticcheese wrote:
Wow, thanks, that's all that's it to it?
Will this work on files ~100MB in size or native PCSX cmdlet is better for this implementation?


A native C# cmdlet implementation is going to be faster - not sure how much faster though. You have access to the PSCX source. You could lift the source for Get-Hash out and create your own simple cmdlet. For a good article on creating cmdlets check this one out by Jim Truher http://msdn.microsoft.com/msdnmag/issues/07/12/PowerShell/default.aspx