Using "-" dashes in powershell scripts?

Shockey

2[H]4U
Joined
Nov 24, 2008
Messages
2,203
Hello Everybody,

Having some challenges with the below portion of my script

I have a array called $nvol that has the following information in it.

Code:
@{index=99; naa-name=514f*************; name=T4-GP-XIO-02-DS011} @{index=100; naa-name=514***********; name=T4-GP-XIO-02-DS012}

I'm trying to extract only the naa-name data but when i try and use the following it complains about the dash.

$nvol[0].naa-name

Any suggestions on how to obtain this little piece of information?
 

Eulogy

2[H]4U
Joined
Nov 9, 2005
Messages
2,401
How are you trying to "extract" it? If I had to guess, it's thinking that the dash is being used as a math operator, so it's interperting it as $nvol[0].naa (minus) name. Try instead $($nvol[0].naa-name)., or maybe single quotes, $nvol[0].'naa-name'. Better would be to build the object / array without the special chars :p
 

Shockey

2[H]4U
Joined
Nov 24, 2008
Messages
2,203
How are you trying to "extract" it? If I had to guess, it's thinking that the dash is being used as a math operator, so it's interperting it as $nvol[0].naa (minus) name. Try instead $($nvol[0].naa-name)., or maybe single quotes, $nvol[0].'naa-name'. Better would be to build the object / array without the special chars :p

Well doing $($nvol[0].'naa-name') work and give me the output I'm looking for.

I can't build the object/array without special characters. It pulling it from a system and using a module build by the vendor.


Thank you for the help!
 
Top