简体   繁体   中英

remote execution(PowerShell) of cmd file doesn't complete

Current PS script:

Invoke-Command -ComputerName RemoteServer007.FQDN.com -ScriptBlock { 
    Set-Variable -Name WOWCONFIG -value "d:\ABCs\WOWzers" `
    | Start-Process "d:\da-folder\Do-It-NOW-Pleez.cmd" 
}

If I log on locally to the server(RemoteServer007.FQDN.com) and execute the cmd file, it runs through all of the lines(commands) within the cmd file.

When I execute it remotely, it gets about 30% of the way through the commands within the cmd file, the PS execution ends without error, but not all of the lines/commands in the cmd file had been executed.

This was discovered by simply configuring each line of the cmd file to output to txt files. I even tried re-ranging the commands in the cmd file, thinking that perhaps there was a specific command that was causing it to exit, but that is not the case.

I'm wondering if there is some timeout or response that PowerShell is not getting? and just quitting almost immediately after starting?

Any ideas or help would be greatly appreciated.

There are a couple of things you can do here:

  • You may have a memory issue. Increasing the value of MaxMemoryPerShellMB might help

    set-item WSMan:\\$target\\Shell\\MaxMemoryPerShellMB -Value 0 -Force

You'd need to run this once on the remote machine before you execute your commands again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM