Hello,
I try to run a batch file on a remote VM via invoke-vmscript, but I do not get it run.
for example I have a file on the remote VM c:\service\test.bat
inside the bat file:
REM net stop wuauserv
net stop wuauserv
reg Delete HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate /v PingID /f
reg Delete HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate /v AccountDomainSid /f
reg Delete HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate /v SusClientId /f
reg Delete HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate /v SusClientIDValidation /f
REM net start wuauserv
net start wuauserv
REM Roll the WU Client...
wuauclt /resetauthorization /detectnow
the invoke would looks like this:
Invoke-VMScript -vm $vmobj -ScriptType bat -ScriptText "C:\Service\test.bat" -GuestUser $GuestUserName -GuestPassword $GuestPassword
'C:\Service\test.bat' is not recognized as an internal or external command
I´m not sure how I could do remote stuff like this. Any ideas?
Thanks
I only get that message when the BAT file does not exist.
Can you check with
Invoke-VMScript -vm $vmobj -ScriptType bat -ScriptText "dir C:\Service" -GuestUser $GuestUserName -GuestPassword $GuestPassword
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
yes that works fine
Directory is valid.
I found the fault.
the file extension was hidden and the batchfile is not a *.bat it is a*.cmd
sorry for that:-)