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:
   1: Get-VMhost myESXHost | Get-SCSILun | where {$_.Model -eq "SYMMETRIX"}
   2: Get-VMhost myESXHost | Get-SCSILun | where {$_.Vendor -eq "EMC"}
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:
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
Resolution:
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*"}
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

Comments

Anonymous said…
Hi Zsoldier,

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

Popular posts from this blog

NSX-T: Release associated invalid node ID from certificate

NSX-T: vCenter and NSX-T Inventory out of Sync (Hosts in vSphere not showing up in NSX-T)

MacOS: AnyConnect VPN client was unable to successfully verify the IP forwarding table modifications.