NSIS 调用 powershell cmdlet Update-MpSignature 未被识别为 cmdlet powershell 的名称

问题描述

我使用 NSIS 调用 powershell 更新 windows 防御者定义,但是当我使用 nsExec::ExecToStack '"powershell.exe" -c Update-MpSignature' 时,它报告错误Update -MpSignature 未被识别为 cmdlet powershell 的名称”。我试过在cmd中调用“powershell.exe”-c Update-MpSignature,效果很好。我也试过 NSIS 官方 psexec.nsh ${PowerShellExecFileLog} call Update-MpSignature in ps1 file ,其他 cmdlet 像 Get-ChildItem、Remove-Item 可以很好地工作,但仍然报错“Update-MpSignature strong> 未被识别为 cmdlet powershell 的名称。有人可以帮助我吗?

解决方法

这听起来像是 64 位问题。

在 64 位系统上,您可以尝试像 this header file 那样执行 $WINDIR\sysnative\windowspowershell\v1.0\powershell.exe