PowerCLI weirdness around Get-SCSILun and where statement
Summary:
Using a where –eq statement against the objects provided by the Get-SCSILun either the vendor or model properties ends w/ 0 objects returned. The following is an example:
Example:
These two examples will likely return 0 results because the Model property is ALWAYS 16 characters and the Vendor property is ALWAYS 8 characters. Each property are padded w/ spaces. How did I figure this out? Like this:
Resolution:
I suggest using –like or –match when querying against these properties. I prefer match, but to each their own. Like so:
I also found this communities post after banging my head against the wall and figuring it out myself w/ some help from marcus:
http://communities.vmware.com/message/1648743
Using a where –eq statement against the objects provided by the Get-SCSILun either the vendor or model properties ends w/ 0 objects returned. The following is an example:
Example:
1: Get-VMhost myESXHost | Get-SCSILun | where {$_.Model -eq "SYMMETRIX"}
2: Get-VMhost myESXHost | Get-SCSILun | where {$_.Vendor -eq "EMC"}
1: $Test = Get-VMhost myESXHost | Get-SCSILun | where {$_.Model -eq "SYMMETRIX"}
2: $Test[0].Model.Length <-- This returns 16
3: $Test[0].Vendor.Length <-- This returns 8
I suggest using –like or –match when querying against these properties. I prefer match, but to each their own. Like so:
1: Get-VMhost myESXHost | Get-SCSILun | where {$_.Model -match "SYMMETRIX"}
2: Get-VMhost myESXHost | Get-SCSILun | where {$_.vendor -like "EM*"}
http://communities.vmware.com/message/1648743
Comments
The "Vendor" property has been fixed long time ago. The PowerCLI team has just spotted your post so the issue with the "Model" property will be addressed in the future. :)
Thanks,
f012rt