Home Use variable in other variable name
Reply: 0

Use variable in other variable name

user581 Published in July 23, 2018, 1:38 pm

I need values of variables which these variable names are concatened by another variable's value.


$GV_R32_var = "testtesttest"
$m = "R32"
(Get-Variable -Name "`$GV_$($m)_var").Value

I receive following error message:

+ (Get-Variable -Name "`$GV_$($m)_var").Value
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: ($GV_R32_var:String) [Get-Variable], ItemNotFoundException
    + FullyQualifiedErrorId : VariableNotFound,Microsoft.PowerShell.Commands.GetVariableCommand
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.481862 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO