Solved

Problem with Select-XML in Powershell

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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Synchronize a new Active Directory domain with an existing Office 365 tenant
The following article is intended as a guide to using PowerShell as a more versatile and reliable form of application detection in SCCM.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

821 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