2016-09-27 159 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 
}