VMware Cloud Community
AutomationStat1
Contributor
Contributor
Jump to solution

Get All Datacenter, Clutsers and Host names

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!

0 Kudos
1 Solution

Accepted Solutions
nicholas1982
Hot Shot
Hot Shot
Jump to solution

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

Nicholas

View solution in original post

1 Reply
nicholas1982
Hot Shot
Hot Shot
Jump to solution

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

Nicholas