$foo="bar"
$bar=22
Invoke-expression ("$"+$foo)
Cheers,
Phil
--
Phil Randal
Infrastructure Engineer
Hoople Ltd | Thorn Office Centre | Hereford HR2 6JT
Tel: 01432 260415 | Email: [email protected]
From: Joseph L. Casale [mailto:[email protected]]
Sent: 29 May 2012 15:40
To: NT System Admin Issues
Subject: Powershell Variables
How does one leverage the evaluated output from some expression as the name of
a new variable?
For example (simplified):
$foo = "bar"
$bar = 22
Write-host $"$foo"
22
Thanks!
jlc
~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~
---
To manage subscriptions click here:
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to
[email protected]<mailto:[email protected]>
with the body: unsubscribe ntsysadmin
"Any opinion expressed in this e-mail or any attached files are those of the
individual and not necessarily those of Hoople Ltd. You should be aware that
Hoople Ltd. monitors its email service. This e-mail and any attached files are
confidential and intended solely for the use of the addressee. This
communication may contain material protected by law from being passed on. If
you are not the intended recipient and have received this e-mail in error, you
are advised that any use, dissemination, forwarding, printing or copying of
this e-mail is strictly prohibited. If you have received this e-mail in error
please contact the sender immediately and destroy all copies of it.
~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~
---
To manage subscriptions click here:
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to [email protected]
with the body: unsubscribe ntsysadmin