Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Signing Powershell Script Returns and "UnknownError" Status

$
0
0

I am trying to self sign some scripts  but keep getting a status of "UnknownError" after the script completes successfully. The strange part is, the script does complete and sign the certs, it just gives a UnknownError status afterwards.

Could someone please assist?

$cert = Get-ChildItem -Path Cert:\LocalMachine\My\XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Set-AuthenticodeSignature C:\scripts\patching-TEST-v2.ps1 -Certificate $cert


SignerCertificate                         Status                                                       Path
-----------------                         ------                                                       ----
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX  UnknownError                                                 patching-TEST-v2.ps1                                       

Here is how I created the cert:

New-SelfSignedCertificateEx -Subject "CN=Generic Powershell CSC" -EnhancedKeyUsage "Code Signing" -StoreLocation LocalMachine -Exportable

However, when I do a Get-ChildItem on the cert, the EnhancedKeyUsageList does not list anything

PS C:\Windows\system32> Get-ChildItem -Path Cert:\localmachine\my\XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX | Format-List -Property *


PSPath               : Microsoft.PowerShell.Security\Certificate::localmachine\my\XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
PSParentPath         : Microsoft.PowerShell.Security\Certificate::localmachine\my
PSChildName          : XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
PSDrive              : Cert
PSProvider           : Microsoft.PowerShell.Security\Certificate
PSIsContainer        : False
EnhancedKeyUsageList : {}
DnsNameList          : {}
SendAsTrustedIssuer  : False
Archived             : False
Extensions           : {System.Security.Cryptography.Oid, System.Security.Cryptography.Oid, System.Security.Cryptography.Oid}
FriendlyName         :
IssuerName           : System.Security.Cryptography.X509Certificates.X500DistinguishedName
NotAfter             : 5/24/2017 4:16:03 AM
NotBefore            : 5/24/2016 4:16:03 AM
HasPrivateKey        : True
PrivateKey           : System.Security.Cryptography.RSACryptoServiceProvider
PublicKey            : System.Security.Cryptography.X509Certificates.PublicKey
RawData              : {48, 130, 3, 20...}
SerialNumber         : XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
SubjectName          : System.Security.Cryptography.X509Certificates.X500DistinguishedName
SignatureAlgorithm   : System.Security.Cryptography.Oid
Thumbprint           : XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Version              : 3
Handle               : 641073664
Issuer               : CN=Generic Powershell CSC
Subject              : CN=Generic Powershell CSC



Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>