VMware Cloud Community
RadarG
Enthusiast
Enthusiast

get-vm script problem (exclude a few vms)

I have a simple script that runs snapshots on a host.

Get-VM | New-Snapshot.....

 how do I exclude a VM "example-vm" from this list?

 

 

Labels (1)
Reply
0 Kudos
1 Reply
LucD
Leadership
Leadership

You can use a Where-clause

Get-VM | Where{$_.Name -notmatch "^example-vm$"} | New-Snapshot....


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos