I have a cluster that is using storage from different storage arrays. These arrays cause me to use different multipath policies. I am trying to write a PowerCLI script to filter all LUNs that are (for example) on an HP array, and then set the policy that I choose.
I use the where clause to successfully filter different attributes of Get-ScsiLun, such as:
Get-ScsiLun -vmhost myhost.mydomain.local -LunType disk | select * | where {$_.multipathpolicy -eq "MostRecentlyUsed"}
That filter works fine and spits out LUNs that are using the MRU policy.
However, when I try to use where to filter the vendor, I don't get any results at all.
Example:
Get-ScsiLun -vmhost myhost.mydomain.local -LunType disk | select * | where {$_.Vendor -eq "HP"}
Perhaps -eq is too restrictive, so I try it with -like:
Get-ScsiLun -vmhost myhost.mydomain.local -LunType disk | select * | where {$_.Vendor -like "HP"}
No dice. No output at all.
As you can probably tell, I want to find all LUNs on my HP array and then set a policy specifically for those LUNs. I could go ahead and put all of the canonicalnames into a file and loop through that, but that's way too much work. Am I going about this the wrong way?
With our IBM storage I noticed that the Vendor property is always 8 characters long (right-padded with blanks).
So I also had to use a -like.
Get-ScsiLun -vmhost $esxName -LunType disk | where {$_.Vendor -like "IBM*"} | %{ $_.Vendor }
Note that you don't have to include the Select in the pipeline.
When you put an asterisk in the string, the -like operator will match every possible character(s) for the asterisk.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
With our IBM storage I noticed that the Vendor property is always 8 characters long (right-padded with blanks).
So I also had to use a -like.
Get-ScsiLun -vmhost $esxName -LunType disk | where {$_.Vendor -like "IBM*"} | %{ $_.Vendor }
Note that you don't have to include the Select in the pipeline.
When you put an asterisk in the string, the -like operator will match every possible character(s) for the asterisk.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I figured out the issue before seeing this post, my case being w/ EMC arrays. An FYI, the Model property seems to always be 16 characters (right-padded w/ blanks).
Is this normal or shouldn't this be a bug?
Oh and -match statement works just as well.
Chris Nakagaki (Zsoldier)