powershell v3.0 - How to retrieve variable in $Global namespace via variable -


i created variable this:

set-variable -name $credvarname -value (get-credential $username) -option readonly -scope global 

i retrieve via variable:

$varname = $credvarname    $global:$varname 

but doesn't work:

$global:$varname

variable reference not valid. '$' not followed valid variable name character. consider using ${} delimit name.

any ideas on how variable via variable?

you're using dynamic variable names, consider using get-variable instead of $global::

get-variable -name $varname -scope global -valueonly 

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -