Powershell

在遠端電腦上使用 PowerShell 導入 PowerShell 腳本證書?

  • August 4, 2016

使用 powershell 編寫腳本時,您必須確保允許您的腳本使用證書在相關機器上執行。如果對腳本進行了任何更改,則必須重新簽署證書才能再次執行腳本;在您對要在多台機器上執行的腳本進行更改之前,這非常有效。

是否可以使用 Powershell 在遠端電腦上為特定腳本導入更新的證書?

如果我更改了已簽名的腳本,我必須將其辭職,否則會出現此錯誤:

. : File \\server\Redirected\yy-XXXX\My Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 cannot
be loaded. The contents of file \\server\Redirected\yy-XXXX\My
Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 may have been tampered because the hash of the file does
not match the hash stored in the digital signature. The script will not execute on the system. Please see "get-help
about_signing" for more details..
At line:1 char:3
+ . '\\server\Redirected\yy-XXXX\My Documents\WindowsPowerShell\Microsof ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   + CategoryInfo          : SecurityError: (:) [], PSSecurityException
   + FullyQualifiedErrorId : UnauthorizedAccess

如果對腳本進行了任何更改,則必須重新簽署證書才能再次執行腳本

這是不正確的。如果對腳本進行了合法更改,則必須重新簽署腳本。無需更改證書,因為它保持不變。

引用自:https://serverfault.com/questions/794901