I have the following script that is functioning (mostly due to the help of this group). I want to add to items to the output of each, the VC it comes from and the VC Cluster. I have the VC names in the text file, but I would like that added to the output file so I can sort later by VC.
In reviewing all the tables for the library information, I can't see how to get the HostID (vc) and the cluster that it comes from thru the ExtensionData.
Does anyone know what string to add to gather the hostid and cluster?
SCRIPT:
$vCenters = Get-content 'C:\VMInventory\vCenters.txt'
Foreach ($vCenter in $vCenters)
{
Connect-VIServer -Server $vCenter –User username –Password password
}
$Data = @()
Foreach ($VIServer in $Global:DefaultVIServers)
{
$NewInfo = Get-VM | select Name, Notes, PowerState, MemoryMB, @{n="HostMemoryUsage";e={$_.ExtensionData.Summary.QuickStats.HostMemoryUsage}}
$Data += $NewInfo
}
$Data | Export-csv –path "C:\VMInventory\Mem_Host_Sum1.csv"