# Signing scripts issue

**URL:** <https://forums.powershell.org/t/signing-scripts-issue/9406>\
**Category:** PowerShell Help\
**Created:** [September 26, 2017, 8:09am UTC](https://forums.powershell.org/t/signing-scripts-issue/9406 "2017-09-26T08:09:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kavramen](https://avatars.discourse-cdn.com/v4/letter/k/9de0a6/32.png) [@kavramen](https://forums.powershell.org/u/kavramen)\
**Post date:** [September 26, 2017, 8:09am UTC](https://forums.powershell.org/t/signing-scripts-issue/9406/1 "2017-09-26T08:09:38Z")

</div>

Ho everyone,

I’m on a route of learning powershell and I’ve experienced an odd issue.  
I’ve created a self-signed certificate (after struggling for a while just took an example from internet, but there is no difference).  
Info about certificate"

```
$cert | fl *

PSPath : Microsoft.PowerShell.Security\Certificate::CurrentUser\My\1AE4C34E2337C9A732A0DBA97ED493D9F4
                           EECD93
PSParentPath : Microsoft.PowerShell.Security\Certificate::CurrentUser\My
PSChildName : 1AE4C34E2337C9A732A0DBA97ED493D9F4EECD93
PSDrive : Cert
PSProvider : Microsoft.PowerShell.Security\Certificate
PSIsContainer : False
EnhancedKeyUsageList : {Code Signing (1.3.6.1.5.5.7.3.3)}
DnsNameList : {Test Code Signing}
SendAsTrustedIssuer : False
EnrollmentPolicyEndPoint : Microsoft.CertificateServices.Commands.EnrollmentEndPointProperty
EnrollmentServerEndPoint : Microsoft.CertificateServices.Commands.EnrollmentEndPointProperty
PolicyId :
Archived : False
Extensions : {System.Security.Cryptography.Oid, System.Security.Cryptography.Oid, System.Security.Cryptog
                           raphy.Oid}
FriendlyName :
IssuerName : System.Security.Cryptography.X509Certificates.X500DistinguishedName
NotAfter : 26.09.2018 16:39:50
NotBefore : 26.09.2017 16:19:50
HasPrivateKey : True
PrivateKey : System.Security.Cryptography.RSACryptoServiceProvider
PublicKey : System.Security.Cryptography.X509Certificates.PublicKey
RawData : {48, 130, 3, 8...}
SerialNumber : 54711E68035CEA9A4752E76967C4D854
SubjectName : System.Security.Cryptography.X509Certificates.X500DistinguishedName
SignatureAlgorithm : System.Security.Cryptography.Oid
Thumbprint : 1AE4C34E2337C9A732A0DBA97ED493D9F4EECD93
Version : 3
Handle : 1583236719936
Issuer : CN=Test Code Signing
Subject : CN=Test Code Signing
```

If I try to sign any script with this certificate I receive “unknow error”:

```
PS D:\> $a[1]

   PSParentPath: Microsoft.PowerShell.Security\Certificate::CurrentUser\My

Thumbprint Subject
---------- -------
1AE4C34E2337C9A732A0DBA97ED493D9F4EECD93 CN=Test Code Signing

PS D:\> $cert = $a[1]
PS D:\> Set-AuthenticodeSignature -Certificate $cert -FilePath .\123_new.ps1

    Directory: D:\

SignerCertificate Status Path
----------------- ------ ----
1AE4C34E2337C9A732A0DBA97ED493D9F4EECD93 UnknownError 123_new.ps1
```

And in the end script is with “Unknow error” line (tho a lot of lines are added in the file):

```
PS D:\> Get-AuthenticodeSignature -FilePath .\123_new.ps1

    Directory: D:\

SignerCertificate Status Path
----------------- ------ ----
1AE4C34E2337C9A732A0DBA97ED493D9F4EECD93 UnknownError 123_new.ps1
```

I also managed to follow these same steps and get result for Get-AuthenticodeSignature as “Not signed”.

I’ve made some reaserch and found out that this might be related to encoding, so I changed encoding to UTF-8, but nothing changed.  
As I understood encoding issue is applicable only for Powershell v1 and v2, and I have PowerShell v5.

So right now I’m stuck and I can’t figure out what is the issue here. Any help would be greatly appreciated 🙂

---

<div class="post-metadata">

**Author:** ![kavramen](https://avatars.discourse-cdn.com/v4/letter/k/9de0a6/32.png) [@kavramen](https://forums.powershell.org/u/kavramen)\
**Post date:** [September 29, 2017, 5:25am UTC](https://forums.powershell.org/t/signing-scripts-issue/9406/2 "2017-09-29T05:25:03Z")

</div>

Found the issue, just needed to add self-signed certificate to trusted.

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:37pm UTC](https://forums.powershell.org/t/signing-scripts-issue/9406/3 "2024-05-16T20:37:27Z")

</div>


