1
A
回答
3
你可能主持PowerShell引擎來檢查這個使用Get-AuthenticodeSignature cmdlet的例如爲:
using System.Collections.ObjectModel;
using System.Management.Automation;
using System.Management.Automation.Runspaces;
private bool VerifyPowerShellScriptSignature()
{
using (var runspaceInvoke = new RunspaceInvoke())
{
string path = "C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\" +
"Modules\\PSDiagnostics\\PSDiagnostics.psm1";
Collection<PSObject> results =
runspaceInvoke.Invoke("Get-AuthenticodeSignature " + path);
Signature signature = results[0].BaseObject as Signature;
return signature == null ? false :
(signature.Status == SignatureStatus.Valid);
}
}
0
如果Get-AuthenticodeSignature
cmdlet可以正確驗證(即如果無效則報告錯誤)並且PSH在目標系統上可用,則可以在C#應用程序中運行PSH。
相關問題
- 1. 運行PowerShell腳本.PS1
- 2. 如何驗證PowerShell腳本正在運行使用C#
- 3. 如何生成自簽名證書並使用它簽署我的PowerShell腳本?
- 4. .ps1腳本中的PowerShell tee-object?
- 5. C#驗證簽名
- 6. PowerShell複製項目PS1腳本
- 7. 如何在C++中使用openssl庫驗證自簽名證書?
- 8. C#\ Exchange 2010 PS1腳本
- 9. PowerShell驗證SAML簽名的XML
- 10. C#使用SignedCms驗證數字簽名
- 11. 如何使用PowerShell腳本到C#中?
- 12. 如何驗證其使用Java腳本
- 13. C#驗證PDF簽名
- 14. C#使用RSA簽名和驗證簽名。編碼問題
- 15. 如何使用jmeter運行Powershell文件(擴展名爲.ps1)?
- 16. 如何驗證PARes簽名?
- 17. 如何在Python中使用ecdsa簽名和驗證簽名
- 18. Azure PowerShell腳本 - 無法驗證參數「名稱」上的參數
- 19. 無法從Powershell命令(控制檯)加載.ps1 powershell腳本
- 20. RSA用PHP簽名並用C驗證#
- 21. Powershell腳本來驗證IIS設置
- 22. PowerShell腳本和表單身份驗證
- 23. 引用文本PS1腳本中調用
- 24. 跨端腳本的用戶名驗證
- 25. 使用PowerShell創建自簽名證書
- 26. Javascript表單驗證。如何使用外部.js驗證腳本
- 27. 使用powershell驗證證書鏈
- 28. 驗證域名白名單的腳本
- 29. 如何在PowerShell腳本中驗證我的密鑰?
- 30. Powershell - 在目錄中的所有ps1文件上運行ps1腳本