How to trust a certificate in Windows Powershell

I use Windows 7and want to run signed scripts from Powershell, security-settingsfor Powershell installed on "all-signed", and my scripts are signed from valid certificatefrom my company. I also added .pfx-fileto the local certificate store (right-clicked the pfx-file and installed).

However, when I run the signed script, I get a message that says:

"Do you want to run software from this untrusted publisher?
File Z:\Powershell Signed Scripts\signed.ps1 is published by CN=[MyCompanyName] and is not trusted on your system. Only run scripts from
 trusted publishers.
[V] Never run  [D] Do not run  [R] Run once  [A] Always run  [?] Help
(default is "D"):"

Since I want to automatically call these scripts on my systems, I would like to add the imported certificate to the trusted list on my system, so that I no longer receive a message when I run a signed script for the first time. How to make my certificate reliable?

+5
source share
2 answers

How to trust a certificate in Windows Powershell

, - mmc:)

, , "":

Get-ChildItem -Recurse cert:\CurrentUser\ |where {$_ -Match "Power"} | Select PSParentPath,Subject,Issuer,HasPrivateKey |ft -AutoSize

( :)

gci cert:\CurrentUser\TrustedPublisher

:

$cert = Get-ChildItem    Certificate::CurrentUser\My\ABLALAH

( : )

$store = New-Object 
$store = New-Object System.Security.Cryptography.X509Certificates.X509Store "TrustedPublisher","LocalMachine"
$store.Open("ReadWrite")
$store.Add($cert)
$store.Close()

, :

ls cert:\CurrentUser\TrustedPublisher
+6

, , script , .

Get-AuthenticodeSignature, script.

Scott .

+2

All Articles