VMware

Resuming Suspended VMs in Workstation w… |VMware Communities

Solved it, now it ONLY resumes suspended VMs in Workstation.

 

if (Get-Process vmware -ErrorAction silentlycontinue)

  {

    cd “C:Program Files (x86)VMwareVMware Workstation”

    $RunningVMs = .vmrun list | select-object -skip 1

    Foreach ($RunningVM in $RunningVMs)

  {

    “Suspending $RunningVM…”

    .vmrun suspend “$RunningVM”

  }

  “Quitting VMWare Workstation..”

  Stop-Process -Name vmware

}

else

  {

    “Opening VMWare Workstation..”

    Start-Process -FilePath “C:Program Files (x86)VMwareVMware Workstationvmware.exe” -WindowStyle Maximized

    cd “C:Program Files (x86)VMwareVMware Workstation”

    $Checkvmems = gci -Include *.vmem -Recurse -Path D:VIRTUALMACHINES

    Foreach ($Checkvmem in $Checkvmems)

  {

    $FolderPath = [System.IO.Path]::GetDirectoryName(“$Checkvmem”)

    $SuspendedVMs = gci -Include *.vmx -Recurse -Path $FolderPath

    Foreach ($SuspendedVM in $SuspendedVMs)

  {

    “Resuming $SuspendedVM”

    .vmrun start “$SuspendedVM”

  }

}

}


Source link

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Close