Link to home
Start Free TrialLog in
Avatar of ckelsoe
ckelsoeFlag for United States of America

asked on

Powershell variable howto question

Hi,

I have this code snippet that works as expected

	$xml = [xml](Get-Content $path)
	$node = $xml.Configuration.Servers.Server

Open in new window


What I really want to do is pass "Configuration.Servers.Server" as a parameter. The various methods I have tried are failing.

So ultimately I want $node = $xml.$XMLPath where $XMLPath =  "Configuration.Servers.Server"
Avatar of Qlemo
Qlemo
Flag of Germany image

Didn't I show you how to do it in your previous question, https://www.experts-exchange.com/questions/28682878/HOWTO-Multidimensional-Arrays.html ?
Avatar of ckelsoe

ASKER

Technically it is a different question - how to combine two variables to get the same result. I did try your method and did not have success with it. The code I have is working fine with the exception of not wanting to hard code the path to the attributes.

I am finding there are multiple ways to perform the same task. I understand that your method is at least one of two methods to change the value of an attribute. As such I do appreciate your help.
ASKER CERTIFIED SOLUTION
Avatar of Qlemo
Qlemo
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ckelsoe

ASKER

Now that did exactly what I wanted!! Thank You.

I was working through your preferred method. Passing "//configuration/servers/server" from the array. Did not get that fully working before I saw this answer. I will play with that method again shortly.

I do appreciate your help very much.