Solved

Problem with Select-XML in Powershell

Posted on 2013-10-26
2
381 Views
Last Modified: 2013-11-24
Hi,

I am having trouble trying to select some XML notes under
in an xml file.

Basically I want to set a variable to be all the
MSI application objects.

I would like to be able select all of them into an array.

I am trying the following statement and it does not seem to work.

It seems my xpath might be wrong?

I have attached the XML file.

Any suggestions?

Thanks,
Ward

$xpath = "/GPO/Computer/ExtensionData"
[xml]$a = Get-Content .\ComputerExample.xml
$b = $a | Select-Xml -XPath $xpath

Open in new window

ComputerExample.xml
0
Comment
Question by:whorsfall
2 Comments
 
LVL 44

Accepted Solution

by:
Rainer Jeschor earned 500 total points
ID: 39604145
Hi Ward,

you might also be able to directly use this:
$b = $a.GPO.Computer.ExtensionData.Extension.MsiApplication

Open in new window


This should return all MsiApplication nodes.

HTH
Rainer
0
 

Author Comment

by:whorsfall
ID: 39605328
Hi,

Thanks for your response. Do u know why the Xpath search failed?

Thanks,

Ward
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to sign a powershell script so you can prevent tampering, and only allow users to run authorised Powershell scripts
This article will help you understand what HashTables are and how to use them in PowerShell.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question