Automation

 View Only
  • 1.  Question about Invoke-VMScript

    Posted Jul 20, 2012 08:26 AM

    I write a vb script to install a software, it can be used like Install.vbs buildnumber Buildname. I can use it in windows cmd like install.vbs 100 abc.

    In PowerCLI, I use following cmds,

    $VMName = 'WINXP_SP3_X86'
    $vm = Get-VM -Name $VMName
    $script = 'C:\Script\InstallAgent.vbs'+' 100'+' abc'
    Invoke-VMScript -ScriptText $script -VM $vm -GuestUser Administrator -GuestPassword password

    But the script doesn't work. I also tried $script = 'wscirpt C:\Script\InstallAgent.vbs'+' 100'+' abc', but got same result.

    If I write a BAT file like wscirpt C:\Script\InstallAgent.vbs %1 %2, then change script to 'C:\Install.BAT 100 abc', it can works. Why I cannot use the script directly?

    And Installation need half an hour, PowerCLI will wait till the script finished. Is there any way to let PowerCLI execute next cmd?

    Thanks,



  • 2.  RE: Question about Invoke-VMScript
    Best Answer

    Posted Jul 20, 2012 08:32 AM

    You can use the Invoke-VMScript -RunAsync parameter to let the command return immediately without waiting for the task to complete.

    To run the vbscript you can use the "-ScriptType Bat" parameter value. If you don't specify this it uses the default value which is PowerShell for Windows servers.

    Message was edited by: RvdNieuwendijk