VMware Cloud Community
AlbertWT
Virtuoso
Virtuoso

Script to list VM with multiple IP address (Windows IIS Webserver multi IP) ?

Hi All,

Is it possible using Powershell to list the IP address of my Webserver VM which has got multiple IP address ?

Thanks in advance.

/* Please feel free to provide any comments or input you may have. */
0 Kudos
2 Replies
ProPenguin
Hot Shot
Hot Shot

Hey this is a very ruff example but should give you what you need to get the information.

Replace servername with your servers name and replace network card brand with your cards brand or you can leave off the where statement.  The where statement just weeds out some of the junk.

Get-WmiObject -computername servername Win32_NetworkAdapterConfiguration | select description,ipaddress | where{$_.description -match "network card brand"}
AureusStone
Expert
Expert

Someone requested something quite similiar recently.  I do not remember the thread but I have a copy of the script.  I have just removed the stuff you don't need.

This script was created by LucD, so I am not taking credit for it. Smiley Happy

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

$IPaddresses = @()

foreach($vm in Get-VM){
    $vm.Guest.Nics | %{
        $row = "" | Select Name, IP, MAC
        $row.Name = $vm.Name
        $row.IP = [String]::Join(',',$_.IPAddress)
        $row.MAC = $_.MacAddress
        $IPaddresses += $row
    }
}

$IPaddresses

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If you only want one VM you could change "($vm in Get-VM)" to "($vm in Get-VM webserver)"

Otherwise you could easily convert this to a oneliner as it doesn't seem like you are looking for a report.

This of course depends on VMware Tools.

0 Kudos