【发布时间】:2017-02-22 09:17:28
【问题描述】:
我已经浏览了与此问题相关的所有可用问题和答案,但我尝试过的任何方法都没有得到所需的,这就是我尝试过的,
这段代码在我正在调用的模块中,如下所示:
Invoke-Command -ScriptBlock {EnsurePowerShellV5 -WMF50Path "D:\wmf50"} @param
$path = "D:\Win8.1AndW2K12R2-KB3134758-x64.msu"
Invoke-Command -ScriptBlock { & "$($env:WINDIR)\system32\wusa.exe" /c "$path /qn" }
我尝试过的其他方式:
Invoke-Command -ScriptBlock {
$pinfo = New-Object System.Diagnostics.ProcessStartInfo
$pinfo.FileName = "$($env:WINDIR)\system32\wusa.exe"
$pinfo.RedirectStandardError = $true
$pinfo.RedirectStandardOutput = $true
$pinfo.UseShellExecute = $false
$pinfo.Arguments = "$path /quiet"
$p = New-Object System.Diagnostics.Process
$p.StartInfo = $pinfo
$p.Start()
$p.WaitForExit()
$stdout = $p.StandardOutput.ReadToEnd()
$stderr = $p.StandardError.ReadToEnd()
Write-Verbose $stderr
Write-Verbose $stdout
}
我使用详细时遇到的错误
System.Management.Automation.RemoteException:[错误] PowerShell 5.0 没有被检测到。请安装并重试。在 System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext,异常异常)在 System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame 帧)在 System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame 帧)在 System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame 框架)
【问题讨论】:
-
哪个变种会触发错误输出?
-
我怀疑这会导致问题
$pinfo.Arguments = "$path /quiet",因为当我删除它时,进程正在启动但未执行
标签: powershell