Hi All,
I've got this script from: Get List of VMs, Datastores and VMDK / path per Cluster however, when I'm trying to modify it to include Storage Format and Disk type with below two lines:
@{N="Storage Format";E={$HardDisk.StorageFormat}}, | ||
@{N="Disk Type";E={$HardDisk.DiskType}} |
This is the overall script:
$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}},
@{N="Drive Size";E={$HardDisk.CapacityGB}},
@{N="Storage Format";E={$HardDisk.StorageFormat}},
@{N="Disk Type";E={$HardDisk.DiskType}}
}
}
}
}
$VmInfo | ft -AutoSize
somehow it is not appearing at all ?
So how to fix this ?
Thanks.
The properties are there, you probably don't see them due to the linelength of the screen.
Cahnge the last line like this, you will see the new properties.
$VmInfo | Format-List
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
The properties are there, you probably don't see them due to the linelength of the screen.
Cahnge the last line like this, you will see the new properties.
$VmInfo | Format-List
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes, you are right Luc 🙂
Exporting to .CSV file shows everything.