Microsoft Virtualization Discussions

get-nclun problems - not all attributes returned


I have a script that converts the lun SerialNumber to hex form for comparison with lun guids in servers that are using the luns.

There is an option to select (1) only those with path matching a wildcard '*xxx* ' or (2) all luns.

The critial statements are

(1) $objlist = get-nclun | where {$_.path -like '*xxx*'} | select Path,SerialNumber,Size

(2) $objlist = get-nclun | select Path,SerialNumber,Size

When I process the list of objects, ie $objlist | % { <do some magic> }

Case (1) - the desired results. SerialNumber is there.

Case (2) - The SerialNumber attribute is missing

How can I force the return of the desired fields in both cases?


Re: get-nclun problems - not all attributes returned


It turns out that I was wrong. The problem is in passing the serial number to the routine that converts it to hex.

(1) $serialnumber | cvt_hex  (always works)

(2) $param = "'" + $serialnumber + "'"

     cvt_hex $param   (fails even though protected by single quotes)

The serialnumber frequently has a + sign, and the powershell parser seems to get hung up even if protected by single quotes.

View solution in original post

Earn Rewards for Your Review!
GPI Review Banner
All Community Forums