You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Invoke-Command与PSExec执行远程脚本:进程名不同且前者失败求助

远程执行Windows升级脚本:Invoke-Command失败,PSExec正常

操作背景

我尝试通过两种方法在远程机器PC1上执行升级脚本,仅PSExec方式可正常完成操作。


方法1:Invoke-Command调用远程本地PS1副本

执行命令:

Invoke-Command -ComputerName PC1 -FilePath "C:\Windows\Temp\LaunchWindowsUpdateAssistance.ps1"

方法2:PSExec调用UNC路径PS1脚本

执行命令:

$ps1 = "\\UNC\PATH\LaunchWindowsUpdateAssistance.ps1"

& "C:\Windows\System32\psexec.exe" -u domain\user.name -p passwordhere -h \\PC1 Powershell.exe -executionpolicy bypass -File $ps1

待执行的PS1脚本内容

$logs = "C:\Windows\Temp\logs"
$msbuild = "C:\windows\temp\Windows10Upgrade9252(21H2).exe"
$Args = "/quietinstall /skipeula /auto upgrade /copylogs $($logs)"
Start-Process -FilePath $msbuild -ArgumentList $args -Wait -PassThru

问题现象对比

  • 方法1执行后,生成的进程名为Windows10UpgraderApp(系统自动命名),运行10分钟后失败
  • 方法2执行后,生成的进程名为指定的Windows10Upgrade9252(21H2).exe,可正常完成升级

内容的提问来源于stack exchange,提问作者DrixlRey

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.10 07:40:34