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
Post a Comment