VMware Cloud Community
vespavbb
Enthusiast
Enthusiast

Invoke-VMScript remote batch file

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 

VCP4,VCP5,VCP6,VCP7,VCP8
Reply
0 Kudos
3 Replies
LucD
Leadership
Leadership

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

Reply
0 Kudos
vespavbb
Enthusiast
Enthusiast

yes that works fine

Directory is valid.

VCP4,VCP5,VCP6,VCP7,VCP8
Reply
0 Kudos
vespavbb
Enthusiast
Enthusiast

I found the fault.

the file extension was hidden and the batchfile is not a *.bat it is a*.cmd

 

sorry for that:-)

 

VCP4,VCP5,VCP6,VCP7,VCP8
Reply
0 Kudos