How to trust a certificate in Windows Powershell

后端 未结 2 1388
孤街浪徒
孤街浪徒 2020-12-18 04:26

I am using Windows 7, and want to run signed scripts from Powershell, the security-settings of Powershell are set to \"all-signe

相关标签:
2条回答
  • 2020-12-18 05:06

    How to trust a certificate in Windows Powershell

    Indeed, you can do this without any mmc :)

    First, check the location of your personal certificate named for example "Power" :

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

    (This one should be empty:)

    gci cert:\CurrentUser\TrustedPublisher
    

    Build the command with the path to your certificate:

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

    Next work on certificate store (Here I work on two certificate store : user & computer)

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

    Check, you should find your certificate :

    ls cert:\CurrentUser\TrustedPublisher
    
    0 讨论(0)
  • 2020-12-18 05:13

    Sounds like you need to verify that the script is signed properly and that you have the correct certificate installed in the correct certificate store.

    Use the Get-AuthenticodeSignature cmdlet to get information about the signed script.

    Also review Scott's guide for signing certificates.

    0 讨论(0)
提交回复
热议问题