ESX host or guest IP address inventory via PowerCLI

IPaddresses = @()

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

$IPaddresses = @()

Get-VMHost | Get-VMHostNetworkAdapter -VMKernel | %{     $row = “” | Select Name, IP, MAC     $row.Name = $_.VMHost.Name     $row.IP = $_.IP     $row.MAC = $_.MAC     $IPaddresses += $row }

$IPaddresses

 

or

 

Get-VMHostNetworkAdapter | select VMhost, Name, IP, SubnetMask | Export-Csv -NoTypeInformation C:\temp\host.csv

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s