Automation

 View Only
  • 1.  Get-view but filtering name with ending of

    Posted Feb 26, 2021 03:05 PM

    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$'}



  • 2.  RE: Get-view but filtering name with ending of
    Best Answer

    Posted Feb 26, 2021 03:31 PM

    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$'}


  • 3.  RE: Get-view but filtering name with ending of

    Posted Feb 26, 2021 03:48 PM

    thanks dude, works a charm!