Hi everyone. I have a problem with adding digital signature to my script. I cannot figure what am I doing wrong.
This are the steps that I did:
First I have created self-signed certificate:
PS New-SelfSignedCertificate -DnsName test -CertStoreLocation Cert:\CurrentUser\My
Second I added certificate to variable:
PS $cert = Get-Item Cert:\CurrentUser\My\7EEEB8FD2421BA55E0F0D6BEE6EF5FB03A3CF2E1
Third I try to add certificate to the script
PS Set-AuthenticodeSignature -FilePath C:\test.ps1 -Certificate $cert
And I get following error:
Set-AuthenticodeSignature : Cannot sign code. The specified certificate is not suitable for code signing.
At line:1 char:1
- Set-AuthenticodeSignature -FilePath C:\test.ps1 -Certificate …
+ CategoryInfo : InvalidArgument: (:) [Set-AuthenticodeSignature], PSArgumentException + FullyQualifiedErrorId : Argument,Microsoft.PowerShell.Commands.SetAuthenticodeSignatureCommand
Can someone help?