Quantcast
Channel: VMware Communities : All Content - All Communities
Viewing all articles
Browse latest Browse all 183671

Script to get the VMFS datastore name and each Number of Path ?

$
0
0

Hi All,

 

I'm trying to list the VMFS datastore & LUN path for a specific set of VMHost or ESXi servers, the below script was created by LucD, but I cannot get the column:

ESXiIP and the VMFS datastore label or name, PSP in the calculated property.


 

 

$esxName='esx1','esx2','esx3'

 

$report=@()

$esxilist=Get-VMHost-Name $esxName

foreach( $esxvmin$esxilist){

    $esx=Get-VMHost-Name $esxvm

    $esxcli=Get-EsxCli-VMHost $esxvm

    $hba=Get-VMHostHba-VMHost $esx-Type FibreChannel |Select- -ExpandProperty Name

    $LUNs=Get-ScsiLun-VmHost $esx

     $TheHost= $_

     $_ |Get-Datastore|Where type -EQ VMFS | select

        @{l="host";e={$TheHost.name}},

        @{l="LUN";e={(Get-View $_).Info.Vmfs.Extent.diskname}},

        @{l="Datastore Name";e={$_.name}},

        @{l="PSP";e={($Luns|where CanonicalName -eq (Get-View $_).Info.Vmfs.Extent.diskname).multipathpolicy}}

    $esxcli.storage.core.path.list() |

        Where{$hba-contains $_.Adapter} |

            Group-Object-Property Device |%{

                $row=""| Select ESXiIP,ESXiName, VMFSDatastoreName1, VMFSDatastoreName2, Lun, NrPaths

                $row.ESXiName=$Esxvm.NetworkInfo.HostName

                $row.ESXiIP=$esxvm.NetworkInfo.ConsoleNic

                $row.Lun= $_.Name

                $row.VMFSDatastoreName1=$esxcli.storage.FullName

                $row.VMFSDatastoreName2=$esxcli.storage.Name

                $row.NrVM= (Get-View-Id $esx.ExtensionData.Vm-Property Name, Config.Template |where {-not $_.ExtensionData.Config.Template}).Count

                $row.NrPaths= $_.Group.Count

                $report+=$row

            }

}

$report|Out-GridView

 

 

Any help would be greatly appreciated.

 

Thank you in advance.


Viewing all articles
Browse latest Browse all 183671

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>