I have 10 datacenters each with a cluster and 2 hosts per cluster:
How would a script look like if i wanted to get all Datacenters, Clusters and Host names attached to a vCenter?
connect-viserver <ip> -user <user> -password <password>
Get-Datacenter | Get-Cluster | Get-Host | -export csv "C:\temp" ?
Thanks!
Hi AutomationStation,
Try this,
Get-VMHost | Select @{N=”Datacenter”;E={Get-Datacenter -VMHost $_}},@{N=”Cluster”;E={Get-Cluster -VMHost $_}}, Name | Export-CSV C:\scripts\dclist.csv -NoTypeInformation
Hi AutomationStation,
Try this,
Get-VMHost | Select @{N=”Datacenter”;E={Get-Datacenter -VMHost $_}},@{N=”Cluster”;E={Get-Cluster -VMHost $_}}, Name | Export-CSV C:\scripts\dclist.csv -NoTypeInformation