As IT Pro you must keep documented all IP Addresses of you Servers and any Hardware that connected in the network.
You know every time what ip address used in your network. So you can avoid conflicts and maybe security issues sometimes.
In small environments it's not so difficult to keep up to date your documentation with all ip addresses.
But in medium and large environments it's difficult.
One of the reason that face very often is that the changes are lot and most of the times forget to keep your documentation up to date.
Today i will explain how can use powershell to show ip addresses of all your Virtual Machines in HYPERV-V Host.
Some of you maybe work in environments with hundreds of Virtual Machines in HYPER-V Host.
Until now to find the ip address of the Virtual Machine you must login and type ipconig in cmd.
Find out how can find all ip addresses with one powersell command
- Login in HYPER-V Host
- Open powershell as administrator
- Most of them we know the get-vm that will bring all the Virtual Machines with specific properties but not the ip addresses.
- Now let's bring all the properties of specific Virtual Machine
get-vm -name Win10 | Format-list *
- We can see property Networkadapters.
- Let's type the following command to see if we get the ip address of the Virtual Machine.
- As you can see we don't get the ip address
get-vm -Name Win10 | Select -Property Networkadapters
- This happened because inside of Networkadapters Property has another collection of properties.
- To expand the Networkadapters property we can use the ExpandPrpoerty and select the ip address.
get-vm -Name Win10 | Select -ExpandProperty Networkadapters | Select -vmname -ipaddress
- If you want to see ip addresses from all Virtual Machines type
get-vm | Select -ExpandProperty Networkadapters | Select -vmname -ipaddress
It's very simple command and you can take a valuable information that can help you and automate one of your task.
I invite you to follow me on Twitter , Google+ or Facebook. If you have any questions, send email to me at info@askme4tech.com.
Have a nice day !!