Hi all
I'm running a script against all our clusters every couple of hours to collect which host (and VC) each VM is running on, so that critical servers can be found quickly in the event a VC fails.
However the script seems to run incredibly slowly, and I suspect its a problem with nested 'gets'. Can anyone confirm ?
ForEach ($Server in $connectioninfo) {
$VISRV = $Server.Management_Server
Write-Host $VISRV
Connect-VIServer $VISRV
Get-VM |where { $_.Powerstate -eq "PoweredOn" -and $_.Name -notlike "UK1*"} | Select @{N="VC_Server";E={$VISRV}}, Name, @{N="Cluster";E={Get-Cluster -VM $_}}, `
@{N="ESX Host";E={Get-VMHost -VM $_}}| Export-Csv -NoTypeInformation -Append $outputfile
Disconnect-VIServer -Confirm:$False
}