Hi
Why I am not able to write any output. I know there are two luns which are not roundrobin but not writing any output.
foreach($VMhost in Get-VMHost "Esxi1"){
foreach($lun in (Get-VMHostHba -VMHost $VMhost -Type FibreChannel |Get-ScsiLun -LunType disk |where {$_.Multipathpolicy -ne "RoundRobin"})){
foreach($ds in (Get-Datastore -VMHost $VMhost)){
$ds.ExtensionData.Info.Vmfs.Extent | %{ if($_.diskName -eq $lun.CanonicalName){
""|Select @{N="Cluster";E={$VMhost.Parent.Name}},
@{N="VMhost";E={$VMhost.Name}},
@{N="DatastoreName";E={$ds.Name}},
@{N="CanonicalName";E={$lun.CanonicalName}},
@{N="PathPolicy";E={$lun.MultipathPolicy}}
}
}
}
}
}
Can you run the following, and compare the two resulting lists based on the CanonicalName?
Are the LUNs with the MostRecentlyUsed policy appearing in any of the datastores?
Get-Datastore |
Select Name,@{N='LUN';E={$_.ExtensionData.Info.Vmfs.Extent.DiskName -join '|'}}
Get-VMHostHba -Type FibreChannel | Get-ScsiLun -LunType disk |
Select CanonicalName,MultiPathPolicy
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Did you try leaving out the Where-clause, and including the Multipathpolicy as a property on the Select-Object?
Does that list those LUNs, with the assumed Path Policy?
foreach($VMhost in Get-VMHost "Esx*"){
foreach($lun in (Get-VMHostHba -VMHost $VMhost -Type FibreChannel |Get-ScsiLun -LunType disk)){
foreach($ds in (Get-Datastore -VMHost $VMhost)){
$ds.ExtensionData.Info.Vmfs.Extent | %{
if($_.diskName -eq $lun.CanonicalName){
""|Select @{N="Cluster";E={$VMhost.Parent.Name}},
@{N="VMhost";E={$VMhost.Name}},
@{N="DatastoreName";E={$ds.Name}},
@{N="CanonicalName";E={$lun.CanonicalName}},
@{N='MultiPathPolicy';E={$lun.MultiPathPolicy}}
}
}
}
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I tried leaving where-clause here I can able to view the output of all the luns except the luns which are using path policy as most recently.
Where I need to do select-object?
If I try like this
Get-VMHostHba -VMHost $vmhost -Type FibreChannel |Get-ScsiLun -LunType disk |where {$_.Multipathpolicy -ne "RoundRobin"}
Output:
The MultiPathPolicy property is already in the output (last column).
Looks like those LUN are not using RoundRobin, but MostRecentlyUsed.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes LucD. But when I execute below script on the same host its not showing any output.
foreach($VMhost in Get-VMHost ){
foreach($lun in (Get-VMHostHba -VMHost $VMhost -Type FibreChannel |Get-ScsiLun -LunType disk |where {$_.Multipathpolicy -ne "RoundRobin"})){
foreach($ds in (Get-Datastore -VMHost $VMhost)){
$ds.ExtensionData.Info.Vmfs.Extent | %{ if($_.diskName -eq $lun.CanonicalName){
""|Select @{N="Cluster";E={$VMhost.Parent.Name}},
@{N="VMhost";E={$VMhost.Name}},
@{N="DatastoreName";E={$ds.Name}},
@{N="CanonicalName";E={$lun.CanonicalName}},
@{N="PathPolicy";E={$lun.MultipathPolicy}}
}
}
}
}
}
That could only mean that the LUNs which do not have RoundRobin are not used in any of the datastores.
Can you check that?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
So you mean to say this lun is mapped to the host but not in use right?
But that is not visible even while adding the datastore.
Should i need to check something else?
Can you run the following, and compare the two resulting lists based on the CanonicalName?
Are the LUNs with the MostRecentlyUsed policy appearing in any of the datastores?
Get-Datastore |
Select Name,@{N='LUN';E={$_.ExtensionData.Info.Vmfs.Extent.DiskName -join '|'}}
Get-VMHostHba -Type FibreChannel | Get-ScsiLun -LunType disk |
Select CanonicalName,MultiPathPolicy
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes those two naa id are not reported when I executed get-datastore.
Ok, then it looks normal that you don't see them in your script at the top.
The LUNs will pass your Where-clause, but then, since they are not used in datastore, they will not pass that test.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes. I am sorry killing your time.
No problem, you're welcome :smileygrin:
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference