i hope can get variable name, but no idea, script like below.
$123 = "test 123"
$456 = "test 456"
$789 = "test 789"
$a = "$123", "$456", "$789"
foreach ($t0 in $a)
{
# want to get variable name, not value
}
cab get variable name?
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Re: cab get variable name?
The request is quite vague. Are you asking how to get the variable as a string.
Code: Select all
PS>$myname = 'Joe Smith'
PS> $varname = '$myname' -replace '\$'
PS> $varname
myname
PS>Get-Variable "$varname"
Name Value
---- -----
varname myname