Quantcast
Channel: VMware Communities : Discussion List - Automation Tools
Viewing all articles
Browse latest Browse all 9071

Why can't I use Powershell to remotely start a VMWare VM using the VMrun tool?

$
0
0

I am a VMWare Workstation user with beginner experience in PowerShell, so I'm not a sysadmin or anything.

 

I found a script to revert and start a VM locally and am trying to use it remotely. I can revert just fine, but nothing happens when I try to start the VM. In the example below, $VMHostMachine is just my localhost for testing purposes. If I remove the -Session parameter from Invoke-Command, it works perfectly, so I know the script is right. Why doesn't it work when I try to invoke the command through a session?

 

    Get-PSSession | Remove-PSSession

    $VMHostMachine | New-PSSession

   

    $rs = Get-PSSession

   

    Write-Debug ("Now starting VM on host: " + $VMHostMachine)

    $script = {param($VMImagePath, $VMConsolePath);

        $QuotedVMPath = "`"{0}`"" -f $VMImagePath

        $Result = Start-Process -FilePath $VMConsolePath -ArgumentList "-T", "ws", "start", $QuotedVMPath -Wait -PassThru -NoNewWindow

    }

   

    Invoke-Command -Session $rs -ScriptBlock $script -ArgumentList $vmConfig.VMImagePathOnHost, $vmConfig.VMRunUtiltyPath


Viewing all articles
Browse latest Browse all 9071

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>