2 Replies Latest reply on Sep 25, 2020 6:18 AM by mrray

    Sorting VM IP against a list from a text file

    mrray Novice

      Happy Friday, PowerCLI community

       

      I have been tasked with getting a list of VMs that have IP addresses that match the IPs on a list, given to me in a text file.

       

      My thought was then to import the text file as an array, look for VMs where the calculated IP address would match any in the array.

       

      What I did looks like this:

       

      $ipadds = Get-Content .\Documents\ntp_queries.txt

       

      Get-VM | where {$_.@{N="IP Address";E={@($_.guest.IPAddress[0])}} -like $ipadds }

      select Name,PowerState, @{N="IP Address";E={@($_.guest.IPAddress[0])}} | Out-GridView

       

      Runs fine, but wit no output, so I assume my filter is not written properly....

       

      any ideas?