VMware Cloud Community
MikePoe
Contributor
Contributor

Listing VM's by Host with wildcard

Evening all,.

wondering if anyone knows of a simple approach to list all VM's for a given Host that contain a wildcard match in the VM Name-i.e, match any VM's called TEST* for a host and return either true/false or null...thanks much.

Reply
0 Kudos
2 Replies
LucD
Leadership
Leadership

Sure, try this

Get-vmhost <hostname> | Get-VM | %{$_.Name -like "TEST*"}

____________

Blog: LucD notes

Twitter: lucd22


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

Reply
0 Kudos
admin
Immortal
Immortal

I would recommend just passing two arguments to Get-VM in this case. -Location can refer to an ESX host.

Get-VM -Location <host> -Name <wildcard>

=====

Carter Shanklin

Read the PowerCLI Blog
[Follow me on Twitter|http://twitter.com/cshanklin]

Reply
0 Kudos