The Way To PowerCLI : Starting and stopping VMs

In this post we will continue our series ” The Way To PowerCLI ” and today we will talk about starting and stopping VMs

With PowerCLI you can manage and automate your VMware infrastructure from the command line. After you connect to vCenter

start with starting VMs

You can use the complete name of the VM, or you can use a wildcard or use the cmdlet in a pipe. so the cmdlet for starting VM


you can start VM with complete name

Start-VM -VM Test01


or from pipe input

Get-VM -Name Test02 | Start-VM


Starting VMs with wildcard

below table show different option

Wildcard character Description Example Matches Does not match
* Matches zero or more characters, starting at the specified position a* A, ag, Apple
? Matches any character at the specified position ?n An, in, on ran
[ ] Matches a range of characters [a-l]ook book, cook, look took
[ ] Matches the specified characters [bc]ook book, cook look

so in first case if we use * it will start all the VMs “test01 and test02”

Start-VM -VM Test*


second case it will match any character instead of the “?”

Start-VM -VM Test0?


this time test01 and test02 will start

Start-VM -VM Test0[12]


you can get more info about Start-VM using Help


now lest move to Stopping VMs 

to stop VM gracefully  VMware tools must be installed on the VM and you will use command

Shutdown-VMGuest -VM "VM Name"

If you try to stop VMs that aren’t running you get errors and your commands don’t continue, so to check the power state of the VMs

Get-VM -name test* | where {$_.PowerState -eq "PoweredOn"}


then you can use

Shutdown-VMGuest -VM test*


if you are not sure what will happen if you run this command  you can add “-WhatIf” at end of the cmdlet and powercli will simulate what will happen if you run this cmdlet

Shutdown-VMGuest -VM test* -WhatIf


Stopping VMs without VMware tools

to stop VM that don’t have VMware tools use cmdlet Stop-VM

Stop-VM -VM tlab*


this will force shutdown the VM without saving anything


Resources :

Supporting Wildcard Characters in Cmdlet Parameters

” The way to VMware PowerCLI” Series Posts :


3 thoughts on “The Way To PowerCLI : Starting and stopping VMs

Comments are closed.