VMware Cloud Community
joshhilditch
Contributor
Contributor
Jump to solution

Get-view but filtering name with ending of

Dumb question, but I'm looking to find all VMs that have "cust.cats.com" in it (usually a server will have something likeDCAD01.cust.cats.com) and only report on them. I have the below which doesn't seem to work. Anyone know how to achieve this?

 

$WindowsVMS = get-view -viewtype virtualmachine -property 'name','guest.guestFamily' -filter @{'guest.GuestFamily'='windowsGuest';'Runtime.PowerState'='poweredOn';'name'='*.cust.cats.com$'}

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Your RegEx expression was nearly correct, just that the quantifier (*) comes after the any character symbol(.)

$WindowsVMS = Get-View -ViewType virtualmachine -Property 'name','guest.guestFamily' -Filter @{'guest.GuestFamily'='windowsGuest';'Runtime.PowerState'='poweredOn';'name'='.*cust.cats.com$'}


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

View solution in original post

0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

Your RegEx expression was nearly correct, just that the quantifier (*) comes after the any character symbol(.)

$WindowsVMS = Get-View -ViewType virtualmachine -Property 'name','guest.guestFamily' -Filter @{'guest.GuestFamily'='windowsGuest';'Runtime.PowerState'='poweredOn';'name'='.*cust.cats.com$'}


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

0 Kudos
joshhilditch
Contributor
Contributor
Jump to solution

thanks dude, works a charm!

0 Kudos