且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

通过PowerShell在远程服务器上运行批处理脚本

更新时间:2023-02-22 20:58:56

尝试替换

invoke-command -computername "SERVER1" -credential $Cred -ScriptBlock -ErrorAction stop { Start-Process "C:\Users\nithi.sundar\Desktop\Test.bat" }

使用

Invoke-Command -ComputerName "Server1" -credential $cred -ErrorAction Stop -ScriptBlock {Invoke-Expression -Command:"cmd.exe /c 'C:\Users\nithi.sund
ar\Desktop\Test.bat'"}