Export (0) Print
Expand All
Collapse the table of content
Expand the table of content
Expand Minimize

Converting the Windows Script Host SignFile Method

Windows PowerShell

Definition: Signs a script using a digital signature.


Assuming you have a certificate that can be used for code signing, Windows PowerShell makes it easy to attach a digital signature to a script. All you have to do is bind to the certificate, then use the Set-AuthenticodeSignature cmdlet to sign the script. For example, in the following block of code the Get-ChildItem cmdlet is used to retrieve a user certificate with the friendly name Script Signer. After the certificate has been retrieved, Set-AuthenticodeSignature then digitally signs the file C:\Scripts\Test.ps1:

$objCertificate = Get-ChildItem Cert:\CurrentUser\My | Where-Object {$_.FriendlyName -eq "Script Signer"}
Set-AuthenticodeSignature C:\Scripts\Test.ps1 -certificate $objCertificate

If you don’t have a certificate that can be used for code-signing you can always create your own by downloading MakeCert.exe. For more information, see the MakeCert home page.

See conversions of other Windows Script Host methods and properties.
Return to the VBScript to Windows PowerShell home page

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
© 2015 Microsoft