how do I get VM info with datacenter location included in a column?
I check $_Extensiondata.config and did not se it under there
Try this:
Get-VM $vm | Format-table Name,
@{Name="Datacenter";Expression={$_.vmhost.parent.parentfolder.parent};a="center"} -a
Tested with a VM in a "clustered" host. I think it may change if host is not in a Cluster.
Hope it works
This isn't the most elegant, but add it as a property with something like this:
$VMs = @()
Foreach ($cluster in (Get-Cluster)) {
Foreach ($vm in (Get-VM)) {
$vm | Add-Member -membertype NoteProperty -name Cluster -value $cluster.Name
$VMs += $vm
}
}
$VMs | Sort Cluster | Select-Object Cluster, Name
Try this:
Get-VM $vm | Format-table Name,
@{Name="Datacenter";Expression={$_.vmhost.parent.parentfolder.parent};a="center"} -a
Tested with a VM in a "clustered" host. I think it may change if host is not in a Cluster.
Hope it works
thank you for locating that object