I am trying to call a batch file remotely in a one liner PowerShell command as such:
PowerShell -ExecutionPolicy UnRestricted invoke-command -ComputerName Server1 -ScriptBlock {cmd.exe /c "\\server1\d$\testPath\test.bat"}
What I want to do is return any exit codes from the test.bat file back to my command. Can anyone give me an idea on how to do this?
(PS, for multiple reasons, I am not able to use PSExec).
Cheers
.bathas a conditional exit in it. Depending on what occurs during the process, the exit may be set to any number of codes (in the 5000 to 5999 range). The last line of the.batisexit _nnnn_if any of the failure conditions are met orexit 0if everything is OK.