在远程计算机上使用 PowerShell 导入 PowerShell 脚本证书?

在远程计算机上使用 PowerShell 导入 PowerShell 脚本证书?

使用 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

答案1

如果对脚本进行了任何更改,则必须重新签名证书才能再次运行该脚本

这是不正确的。如果对脚本进行了合法的更改,则必须重新签名该脚本。无需更改证书,因为它保持不变。

相关内容