AutomationStat1
Contributor
Contributor

Get All Datacenter, Clutsers and Host names

Jump to solution

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

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

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