VMware Cloud Community
shaggy_041086
Enthusiast
Enthusiast
Jump to solution

Array of all IP address in vCenter

I am trying to populate a list of all VMs with VMTools and IP information and am exporting it to CSV

I have got some VMs which have multiple IPs so I wanted to list all the IPs in the respective IP column

For eg:-

Guest          IP          VMTools Version

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

VM1        10.1.1.1      8290

VM2        10.1.2.1      7302

               10.1.2.3

               10.1.2.5

VM3        10.4.1.5      8295

.

.

.

.

etc.

I m using something like this -

Foreach ($Guests in (Get-VM -name (Get-Content $VMList))) {
     $VM = Get-VM $Guests
     $row = New-Object System.Object
     $row | Add-Member -Type NoteProperty -Name "Guest" -Value $Guests
     $row | Add-Member -Type NoteProperty -Name "IP" -Value $VM.Guest.IPAddress | %{[String]::Join(',',$_.IPAddress)}
     $row | Add-Member -Type NoteProperty -Name "VMTools Version" -Value $VM.ExtensionData.Guest.ToolsVersion
     $row
     $stats += $row
}

But in the final output, it shows as "System.String[]"

Please Help!!!

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try changing that line as follows

$row | Add-Member -Type NoteProperty -Name "IP" -Value ([String]::Join(',',$VM.Guest.IPAddress))


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

Reply
0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

Try changing that line as follows

$row | Add-Member -Type NoteProperty -Name "IP" -Value ([String]::Join(',',$VM.Guest.IPAddress))


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
shaggy_041086
Enthusiast
Enthusiast
Jump to solution

Thanks!!

Reply
0 Kudos