You could do something like this.
It assumes that the LUNs you want to check are in the array $TgtLUN
ForEach-Object -Process {
$_.ExtensionData.Info.Vmfs.Extent.DiskName
}
$TgtLUN | where{$dsLun -contains $_}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
if yu could conver this to get-view way as this is terribly slow .how it is taking 2 hours to generate outout .
it has killed the very concept of automation .
Seen the changes, which script are you currently running?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
$vmfsdatastore=Get-Datastore|?{$_.Type -eq "VMFS"}
$TgLUN=$vmfsdatastore|get-scsilun|?{$_.multipathpolicy -ne "roundrobin" -and $_.canonicalname -notlike "t10.*"}
$dsLUN = Get-Datastore | where{$_.ExtensionData.Summary.MultipleHostAccess} |
ForEach-Object -Process {
$_.ExtensionData.Info.Vmfs.Extent.DiskName
}
$TgtLUN | where{$dsLun -contains $_}
if yu can suggest below works fine
ForEach-Object -Process {
Get-VMHost -RelatedObject cluster -PipelineVariable esxi |
ForEach-Object -Process {
Get-Datastore -RelatedObject $esxi|?{$_.Type -eq "VMFS" -and $_.ExtensionData.Summary.MultipleHostAccess -eq "true"} -PipelineVariable datastore|
ForEach-Object -Process {
$_|get-scsilun|?{$_.multipathpolicy -ne "roundrobin" -and $_.canonicalname -notlike "t10.*"}
Select @{N='cluster';E={$cluster.Name}},
@{N='host';E={$esxi.name}},
@{N='shareddatastore';E={$datastore.name.name}},
@{N='scsilunwithpathpolicyotherroundrobin';E={$_.name}}
}
}}
What is the purpose of that 1st line with ForEach-Object?
There is nothing in the pipeline at that point.
Are you saying this version works at an acceptable speed?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
sorry i wanted to type below .if yu getting resonse out of it and can make it faster ??
Get-cluster -PipelineVariable cluster |
ForEach-Object -Process {
Get-VMHost -location $cluster -PipelineVariable esxi |
ForEach-Object -Process {
Get-Datastore -RelatedObject $esxi|?{$_.Type -eq "VMFS" -and $_.ExtensionData.Summary.MultipleHostAccess -eq "true"} -PipelineVariable datastore|
ForEach-Object -Process {
$_|get-scsilun|?{$_.multipathpolicy -ne "roundrobin" -and $_.canonicalname -notlike "t10.*"}
Select @{N='cluster';E={$cluster.Name}},
@{N='host';E={$esxi.name}},
@{N='shareddatastore';E={$datastore.name.name}},
@{N='scsilunwithpathpolicyotherroundrobin';E={$_.name}}
}
}}
Try something like this
ForEach-Object -Process {
Get-View -Viewtype Hostsystem -SearchRoot $cluster.MoRef -Property Name,Datastore -PipelineVariable esxi |
ForEach-Object -Process {
$esxcli = Get-EsxCli -VMHost $esxi.Name -V2
Get-View -Id $esxi.Datastore -Property Name,Summary,Info -PipelineVariable ds | where{$_.Summary.Type -eq 'VMFS' -and $_.Summary.MultipleHostAccess} |
ForEach-Object -Process {
$ds.Info.Vmfs.Extent.DiskName |
where{$_ -notmatch "^t10\."} |
ForEach-Object -Process {
$esxcli.storage.nmp.device.list.Invoke(@{device=$_}) |
where{$_.PathSelectionPolicy -ne 'VMW_PSP_RR'} |
select @{N='Cluster';E={$cluster.Name}},
@{N='Host';E={$esxi.Name}},
@{N='SharedDatastore';E={$ds.Name}},
@{N='ScsiLunWithPathpolicyNotRoundRobin';E={$_.Device}}
}
}
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
thanks luc i am checking this code in few minutes .
however if yu can see the attched file .
in this one volume which is presented to 5 esxi hosts and one of them is using MRU path policy .
if yu can comment on following two points one more time .
so to be safer side i need to put this host in maintenace mode to change the path policy otherwise we might end up loosing connection to volume for some time .
also if you can tell me what will be the corresponding datastore for that naa id .
I'm not sure that placing the ESXi node in maintenance mode is a requirement to safely change the multipath policy of a LUN.
In fact, I never witnessed it.
On the other hand, placing the node in maintenance will avoid any potential issues, should there be some.
To find the datastore from the LUN, you could something like this
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
well if i put that naa id in below i dont get any output but this volume is presented to cluster .dont know why its not part of datastore .
Get-Datastore | where{$_.ExtensionData.Info.Vmfs.Extent.DiskName -contains 'naa.123451234512345123451234512345'}
also below gives info for other hosts but not for this wherin
$e=get-esxcli -vmhost "nameofesxi" -v2
When you use the V2 switch, the method is not list() but list.Invoke()
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
thanks .i dont find that naa id in the extent list.
from weclient i found its not been consumed .its presented to cluster but not formatted with vmfs to form datastore .
so i dont think chnaging path policy to it will give any advantages here as no vms on it .
If there is nothing on there, it can probably not harm to change the path policy either.
Or ask your storage team to remove the zoning, so it is not visible anymore.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks Luc for your support and patience .