VMware Cloud Community
houghtp
Contributor
Contributor

Datastore Name and Mulitpath Info

hi

how can i get datastore name and multipath info into a nice report. so for example

datastore name | multipath policy | preferred path

datastore1 fixed 0:0:22

i can get each individual property but can't seem to combine them in this way.

thanks

22 Replies
vechiattoa
Contributor
Contributor

Luc,

Please how to export to csv?

0 Kudos
LucD
Leadership
Leadership

The ForEach doesn't place anything in the pipeline.

Use the call operator (&) to bypass this

$esxhost = <esxhostname>

$hss = Get-View (Get-VMHost -Name $esxhost | Get-View).ConfigManager.StorageSystem

&{foreach($mount in $hss.FileSystemVolumeInfo.MountInfo){

     if($mount.Volume.Type -eq "VMFS"){

          foreach($ext in $mount.Volume.Extent){

               foreach($lun in $hss.StorageDeviceInfo.MultipathInfo.Lun){

                    if(($hss.StorageDeviceInfo.ScsiLun | where{$_.Key -eq $lun.Lun}).CanonicalName -eq $ext.DiskName) {

                         foreach($Path in $lun.path){

                              if ($Path.pathstate -eq "active"){

                                   $activepath = $path.name

                                   break

                              }

                         }

                         break

                    }

               }

               Write-Host $mount.Volume.Name $lun.Policy.Policy $ext.DiskName $activepath

          }

     }

}} | Export-Csv c:\report.csv -NoTypeInformation -UseCulture 


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

vechiattoa
Contributor
Contributor

Luc,

Thank you so much.

0 Kudos