VMware Cloud Community
bradley4681
Expert
Expert

Simple Datastore Report

Trying to make a report that connects to a VC and lists the datastores, the hosts they are connected to, and the cluster names of those hosts and export to CSV

So,

datastore, host, cluster

Cheers,

Bradley Sessions

If you found this or other information useful, please consider awarding points for "Correct" or "Helpful".

Cheers! If you found this or other information useful, please consider awarding points for "Correct" or "Helpful".
0 Kudos
1 Reply
LucD
Leadership
Leadership

You could do something like this

$report = @()
foreach($ds in (Get-Datastore)){
  foreach($esx in ($ds | Get-VMHost)){
     $row = "" | Select Datastore,Host,Cluster  
     $row.Datastore = $ds.Name
     $row.Host = $esx.Name
     $row.Cluster = ($esx | Get-Cluster).Name
     $report += $row
   } 
}
$report

____________

Blog: LucD notes

Twitter: lucd22


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos