Good day,
I have the following one-liner which i'm using to search VM by specific IP address via Slack (hubot integrated with vSphere and Slack):
Get-View -ViewType VirtualMachine -Filter @{”Guest.IpAddress”=”$1"} | Select Name, @{N="Folder";E={Get-View $_.Parent | Select -ExpandProperty Name}}
where $1 is the IP address. If the IP address is for example 192.168.0.13 the output contains all VMs starting with IP 192.168.0.13 (wildcard output, same as @{”Guest.IpAddress”=”^$1"} ) :
Name -- Folder
vm4 Test 192.168.0.13
vm15 Test 192.168.0.135
vm23 Test 192.168.0.139
How can i filter the output to list only the VM with the exact IP which im searching for (in that example it should list only vm4)?
The second question is - how can i search within all VM NICs? Currently the output return results only if the IP address is assigned to the first NIC but i have many VMs with multiple networks.
Thank you for your time!
Have a great day!