2016-09-27 160 views
1

在我们的环境中,我们使用的两种主要脚本语言是VBScript/WScript和PowerShell。我们的PowerShell已设置好,所有脚本都必须进行数字签名。在PowerShell ISE中,我们添加了一个菜单项,它保存当前的工作脚本并对其进行数字签名。我们目前对VBS/Wscript使用不同的编辑器。 VSCode中有没有办法让我们在环境中运行一个函数来对当前的PowerShell脚本进行数字签名?[VSCODE]中的数字签名脚本

回答

0

找到我的答案:

Register-EditorCommand -Name SignCurrentScript -DisplayName 'Sign Current Script' -ScriptBlock { 
    $cert = (Get-ChildItem Cert:\CurrentUser\My -CodeSigningCert)[0] 
    $currentFile = $psEditor.GetEditorContext().CurrentFile.Path 
    Set-AuthenticodeSignature -Certificate $cert -FilePath $currentFile 
}