I have been struggling getting powershell to run Psexec. It works fine for single line commands. but i need to call SCOM to put the server in maintenance mode through Psexec...
$output = .\pstools\PsExec.exe \\scomserver-u $user -p $password -w c:\scom -h "c:\scom\agentmm.exe servertoputinmaintenancemode 4 Automated Maintenance Mode Now +45m"
I have tried to put quotes after every sentence but it doenst help.. I get this error
PsExec v1.98 - Execute processes remotely Copyright (C) 2001-2010 Mark Russinovich Sysinternals - www.sysinternals.com
The handle is invalid.
Connecting to scomservername...Starting PsExec service on scomservername...C onnecting with PsExec service on scomservername...Error communicating with PsExec servi ce on scomservername: