[VSCODE] 中的数字签名脚本

Digitally Signing scripts in [VSCODE]

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

找到我的答案:

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
}