Automation

 View Only
  • 1.  Invoke-VMScript remote batch file

    Posted Jun 22, 2021 09:21 AM

    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 



  • 2.  RE: Invoke-VMScript remote batch file

    Posted Jun 22, 2021 09:54 AM

    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


  • 3.  RE: Invoke-VMScript remote batch file

    Posted Jun 22, 2021 11:32 AM

    yes that works fine

    Directory is valid.



  • 4.  RE: Invoke-VMScript remote batch file

    Posted Jun 22, 2021 11:37 AM

    I found the fault.

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

     

    sorry for that:-)