Problem
You want to verify the digital signature of a PowerShell script or formatting file.
Solution
To validate the signature of a script or formatting file, use the GetAuthenticodeSignature cmdlet:
PS >GetAuthenticodeSignature .\test.ps1
Directory: C:\temp
SignerCertificate Status Path
FD48FAA9281A657DBD089B5A008FAFE61D3B32FD Valid test.ps1
Discussion
The GetAuthenticodeSignature cmdlet gets the Authenticode signature from a file. This can be a PowerShell script or formatting file, but the cmdlet also supports DLLs and other Windows standard executable file types.
By default, PowerShell displays the signature in a format that summarizes the certificate and its status. For more information about the signature, use the FormatList cmdlet, as shown in Example 162.
Example 162. PowerShell displaying detailed information about an Authenticode signature
PS >GetAuthenticodeSignature .\test.ps1 | FormatList
SignerCertificate : [Subject] CN=PowerShell User
[Issuer] CN=PowerShell Local Certificate Root
[Serial Number] 454D75B8A18FBDB445D8FCEC4942085C
[Not Before] 4/22/2007 12:32:37 AM
[Not After] 12/31/2039 3:59:59 PM
[Thumbprint] FD48FAA9281A657DBD089B5A008FAFE61D3B32FD
TimeStamperCertificate : Status : Valid StatusMessage : Signature verified. Path : C:\temp\test.ps1
For more information about the GetAuthenticodeSignature cmdlet, type GetHelp GetAuthenticodeSignature.