How can I suspend a VM on VMware workstation via Powershell ?

As there is no API for Powershell in VMware worksation, we need to use the built-in tool called ‘vmrun.exe”

This utility can be used to control virtual machines and allows the following operations: start (power on), stop (power off), reset (reboot), suspend (but allow local work to resume), pause (without interrupting), and unpause (continue)

=====Suspend your VMs======

cd “C:\Program Files (x86)\VMware\VMware Workstation”

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

Foreach ($RunningVM in $RunningVMs)
{
“Suspending $RunningVM…”
.\vmrun suspend “$RunningVM”
}

 

====Resume your VMs ====

cd “C:\Program Files (x86)\VMware\VMware Workstation”

$SuspendedVMs = gci -Include *.vmx -Recurse -Path C:\VMs

Foreach ($SuspendedVM in $SuspendedVMs)
{
.\vmrun start “$SuspendedVM”
}

Leave a Reply

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