签署PowerShell脚本

时间:2010-09-01 19:28:17

标签: powershell

我正在尝试签署我的powershell脚本,以便我可以毫无问题地执行它们。我在我的系统上创建了代码签名证书,可以从PowerShell内部查看。当我去签名时,我不断收到错误

PS C:\xxadmin> get-childitem cert:\CurrentUser\my -codesign


    Directory: Microsoft.PowerShell.Security\Certificate::CurrentUser\my


Thumbprint                                Subject
----------                                -------
6B43052FDE320530CD77B260CC9BD046B68D2351  CN=PowerShell User


PS C:\xxadmin>

尝试使用以下命令进行签名。

Set-AuthenticodeSignature C:\xxadmin\iisbackup.ps1 @ (get-childitem cert:\CurrentUser\My -codesigning) [0]

这是我得到的错误。

  

源文本中无法识别的令牌。在   line:1 char:52   + Set-AuthenticodeSignature C:\ xxadmin \ iisbackup.ps1<<<< @   (get-childitem cert:\ CurrentUser \ My    - 编程)[0]       + CategoryInfo:ParserError:(:) [],   ParentContainsErrorRecordException       + FullyQualifiedErrorId:UnrecognizedToken

此脚本签名后,我还需要在每台要执行脚本的机器上安装证书吗?

1 个答案:

答案 0 :(得分:4)

@必须在开场(旁边。索引器[0]和结束)相同,例如:

Set-AuthenticodeSignature C:\xxadmin\iisbackup.ps1 `
    @(get-childitem cert:\CurrentUser\My -codesigning)[0]

关于您的其他问题,这取决于您使用的证书类型。如果是自生成然后是,则需要将其复制到每台机器。如果它是官方的Verisign类型证书,那么您不需要将其安装在其他机器上。

相关问题