Monday, November 23, 2015

PowerCLI script to match a rogue IP address to a VM.

Here's a quick way of finding which system has a specified IP address assigned to it. You have a rogue IP address and don't know which VM is assigned to it.


$match_address = "192.168.10.27"
Get-VM | %{
      $vmIPs = $_.Guest.IPAddress
      foreach($ip in $vmIPs) {
          if ($ip -eq $match_address) {
              "Found VM with matching address: {0}" -f $_.Name
          }
      }
  }

No comments:

Post a Comment