Wednesday, May 19, 2010

PowerShell – Windows

Thought it will be interesting to share with you all , these steps involved in certifying PowerShell scripts.
I tried it on Windows 7. So here it is.
Go to C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin>
Run the command
C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin>makecert.exe -n "CN=PowerShell Local Certificate Root" -a sha1 -eku 1.3.6.1.5.5.7.3.3 -r -sv root.pvk root.cer -ss Root -sr localMachine
You will be prompted to create PrivateKey Password
Following which you will be required to enter the Private Key to successfully create the certificate.
type mmc, and in the console, add (Ctrl+M) Certificate
image
Under trusted root certifications you should be able to see the PowerShell Certificate you created for code signing.
image
now run this command
C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin>makecert -pe -n "CN=PowerShell User" -ss MY -a sha1 -eku 1.3.6.1.5.5.7.3.3 -iv root.pvk -ic root.cer
and you will be prompted to enter your password again.
image
Now in PowerShell to verify your certificate type the following command , and you should see some thing like this.
image
Here is the final fun.. that uve been waiting for.
in my case I had a simple ps1 file which needed to be signed, and I signed it using the command
image
you need not be in a specific directory to sign your code. Its your option of where ever u wana be, like in Starbucks etc.

No comments:

Post a Comment