LucD
Leadership
Leadership

The IPAddress property is an array, you can always join the elements of this array into 1 string.

But note that you will get these same IP addresses (VM-level) displayed for each harddisk attached to that VM.

Something like this

$VmInfo = ForEach ($Datacenter in (Get-Datacenter | Sort-Object -Property Name)) {
  ForEach ($Cluster in ($Datacenter | Get-Cluster | Sort-Object -Property Name)) {
    ForEach ($VM in ($Cluster | Get-VM | Sort-Object -Property Name)) {
      ForEach ($HardDisk in ($VM | Get-HardDisk | Sort-Object -Property Name)) {
        "" | Select-Object -Property @{N="VM";E={$VM.Name}},
        @{N="Datacenter";E={$Datacenter.name}},
        @{N="Cluster";E={$Cluster.Name}},
       
@{N="IP";E={[string]::Join(',',$VM.Guest.IPAddress)}},
       
@{N="Hard Disk";E={$HardDisk.Name}},
        @{N="Datastore";E={$HardDisk.FileName.Split("]")[0].TrimStart("[")}},
        @{N="VMConfigFile";E={$VM.ExtensionData.Config.Files.VmPathName}},
        @{N="VMDKpath";E={$HardDisk.FileName}},
       
@{N="VMDK Size";E={($vm.extensiondata.layoutex.file|?{$_.name -contains $harddisk.filename.replace(".","-flat.")}).size/1GB}}       }     }   } } $VmInfo | Export-Csv -NoTypeInformation -UseCulture -Path "VmInfo.csv"


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

Reply
0 Kudos