VMWare Workstation: Start VMs on user login

I want to start a certain list of VMWare Workstation virtual machines on machine boot. I created a Scheduled task that on logon runs:

"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NonInteractive -File "C:\Users\Tools\Start-VMs.ps1"

And the contents of Start-VMs.ps1 are:

$vmrun = 'C:\Program Files (x86)\VMware\VMware Workstation\vmrun.exe'
$vmlist = @('C:\Virtual Machines\Ubuntu\Ubuntu.vmx', 'I:\Virtual Machines\UbuntuServer\UbuntuServer.vmx')

$authd = Get-Service -Name VMAuthdService
if($authd.Status -ne 'Running') {
    $authd.Start()
}

foreach($vm in $vmlist) {
    & $vmrun start "$vm"
}

Published: October 05 2015

blog comments powered by Disqus