Powershell 7 and „Trusted Publishers“

Untrusted Publishers

Recently, I installed `Powershell 7` and was using it for a while. After settings my code security to AllSigned, I got the following error.

File C:\…\PSReadLine.format.ps1xml is published by CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US and is not trusted on your system. Only run scripts from trusted publishers.

This is a little bit annoying because the module is signed so it should work. Powershell shows the following error message.

The error is caused by an expired certificate and affects more modules e.g. `Microsoft.PowerShell.Archive`.

Trust the Publisher

To trust the publisher, the certificate must be added to user’s or machine’s certificate store in „Trusted Publishers“. But hot to get the certificate?

The certificate can be found in `C:\program files\powershell\7\Modules\PSReadLine\PSReadLine.cat`. After opening the file, select `View Signature` and click `View Certificate`. This dialogue provides the option `Install Certificate` to the „Trusted Publishers“.

After adding the certificate, Powershell loads the module without any questions.

Kommentare

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert