Solved

Problem with Select-XML in Powershell

Posted on 2013-10-26
2
379 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

The article will show you how you can maintain a simple logfile of all Startup and Shutdown events on Windows servers and desktops with PowerShell. The script can be easily adapted into doing more like gracefully silencing/updating your monitoring s…
In this previous article (https://oddytee.wordpress.com/2016/05/05/provision-new-office-365-user-and-mailbox-from-exchange-hybrid-via-powershell/), we made basic license assignments to users in O365. When I say basic, the method is the simplest way …
This video discusses moving either the default database or any database to a new volume.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now