VMware Cloud Community
Mallik7
Enthusiast
Enthusiast
Jump to solution

In need of a script to check ESXi hosts multipath

Hello,

Can some one help me to provide a ESXi hosts multipath validation script? - ESXi OS version 6.5

TIA

1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Sure.

If you place the names of the ESXi nodes in a .txt file, one name per line, you could do something like this.

$esxNames = Get-Content -Path .\esxnames.txt

$report = foreach ($esx in Get-VMHost -Name $esxNames)

{

   $esxcli = Get-EsxCli -VMHost $esx -V2

   foreach ($adapter in $esxcli.storage.core.adapter.list.Invoke() | where { $_.Driver -match 'fc' })

   {

   $esxcli.storage.core.path.list.Invoke() | where { $_.Adapter -eq $adapter.HBAName } |

   Group-Object -Property Device |

  Select @{N = 'VMHost'; E = { $esx.Name } },

   @{N = 'HBA'; E = { $adapter.HBAName } },

   @{N = 'Device'; E = { $_.Name } },

   @{N = 'Path#'; E = { $_.Group.Count } },

   @{N = 'PathStatus'; E = { ($_.Group.State | Sort-Object -Unique) -join ',' } }

   }

}


$report | Export-Csv .\report.csv -NoTypeInformation -UseCulture

---------------------------------------------------------------------------------------------------------

Was it helpful? Let us know by completing this short survey here.


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

View solution in original post

4 Replies
LucD
Leadership
Leadership
Jump to solution

What exactly do you mean by "validation"?


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

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Reply
0 Kudos
Mallik7
Enthusiast
Enthusiast
Jump to solution

thank you so much. I couldn't find that before.

however, can you help to modify that script in the below manner please -

the existing script generating the output of the entire vCenter. But, I would like only few esxi hosts mulitpath status from the vCenter.

say example, in one of the vCenter, there are about 200 ESXi hosts, but, I want only 20 hosts multipath status is required. I want to input the host names how many that I needed.

Could you please help to modify the script that way ?

TIA

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Sure.

If you place the names of the ESXi nodes in a .txt file, one name per line, you could do something like this.

$esxNames = Get-Content -Path .\esxnames.txt

$report = foreach ($esx in Get-VMHost -Name $esxNames)

{

   $esxcli = Get-EsxCli -VMHost $esx -V2

   foreach ($adapter in $esxcli.storage.core.adapter.list.Invoke() | where { $_.Driver -match 'fc' })

   {

   $esxcli.storage.core.path.list.Invoke() | where { $_.Adapter -eq $adapter.HBAName } |

   Group-Object -Property Device |

  Select @{N = 'VMHost'; E = { $esx.Name } },

   @{N = 'HBA'; E = { $adapter.HBAName } },

   @{N = 'Device'; E = { $_.Name } },

   @{N = 'Path#'; E = { $_.Group.Count } },

   @{N = 'PathStatus'; E = { ($_.Group.State | Sort-Object -Unique) -join ',' } }

   }

}


$report | Export-Csv .\report.csv -NoTypeInformation -UseCulture

---------------------------------------------------------------------------------------------------------

Was it helpful? Let us know by completing this short survey here.


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