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
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
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
Thank you LucD !