I have about 8 vCenters that i want to gather information on all vms and send an email telling me what host they are on and what vCenter they live on, here is what i have but man it takes FOREVERRRRR
any performance tweaks tips?
$vc = 'AllVMs'
$date = (Get-Date -format u) -replace " ","_" -replace "-","_" -replace ":","_"
$name = "$vc"+"_$date"
$latest = "$vc"+"_Latest"
$vmsonvc = get-vm | select name, @{N="IPAddress"; E={$_.Guest.IPAddress[0]}}, @{N="VMDnsName"; E={$_.ExtensionData.Guest.Hostname}}, NumCPUs,MemoryGBs, Powerstate,VMHost, @{N="vCenter";E={$_.ExtensionData.CLient.ServiceUrl.Split('/')[2]}} | sort name
$vmsonvc | export-csv "C:\WhereAreTheVMs\$name.csv" -NoTypeInformation
sleep 30
$vmsonvc | Export-Csv -Force C:\WhereAreTheVMs\$latest.csv -NoTypeInformation