VMware Cloud Community
Virtualduty
Enthusiast
Enthusiast
Jump to solution

Need help to get multipathing policy

Hello All,

I am using the below script to get path status, need help to add multipathing policy type and also I want to run it against specific ESxi cluster,

Any help will be greatly appreciated,

&{foreach($esx in Get-VMHost){

    $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} |

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

            Device,RuntimeName,State

    }

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

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try like this

$clusterName = 'cluster1'

$report = foreach($esx in Get-Cluster -Name $clusterName | Get-VMHost){

    $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} |

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

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

            Device,RuntimeName,State,

            @{N='PathPolicy';E={$esxcli.storage.nmp.device.list.Invoke(@{device="$($_.Device)"}) | select -ExpandProperty PathSelectionPolicy}}

    }

}

$report | Export-Csv C:\mylocation\report.csv -NoTypeInformation -UseCulture


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

View solution in original post

2 Replies
LucD
Leadership
Leadership
Jump to solution

Try like this

$clusterName = 'cluster1'

$report = foreach($esx in Get-Cluster -Name $clusterName | Get-VMHost){

    $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} |

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

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

            Device,RuntimeName,State,

            @{N='PathPolicy';E={$esxcli.storage.nmp.device.list.Invoke(@{device="$($_.Device)"}) | select -ExpandProperty PathSelectionPolicy}}

    }

}

$report | Export-Csv C:\mylocation\report.csv -NoTypeInformation -UseCulture


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

Virtualduty
Enthusiast
Enthusiast
Jump to solution

Thank you LucD !

0 Kudos