Microsoft Virtualization Discussions

get-nclun problems - not all attributes returned

collins_richey
3,063 Views

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?

1 ACCEPTED SOLUTION

collins_richey
3,063 Views

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

1 REPLY 1

collins_richey
3,064 Views

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.

Public