Questions tagged [select-xml]

Select-Xml is a powershell cmdlet that finds a text in xml documents.

Documentation: Technet

19 questions
12
votes
2 answers

PowerShell select-xml xpath doesn't seem to work

I'm trying to use select-xml to root out a few things from a SharePoint solution. I have a solution directory that contains a number of features, and rather than open each feature.xml and select names of features by hand and put them in a list, I…
Ben Collins
  • 20,538
  • 18
  • 127
  • 187
8
votes
1 answer

Surgical XML editing with Powershell

I'm working with csproj files using Powershell to perform large-scale editing of project references. So far I've managed to edit the Include attributes on ProjectReferences using the following lines: $projectXml = [xml](Get-Content…
bwerks
  • 8,651
  • 14
  • 68
  • 100
3
votes
1 answer

Xpath not operator in Select-Xml via Powershell

I'm working with csproj files, and I'm trying to write a cmdlet that extracts all of the files referenced by a project file. This will include all of the Compile, EmbeddedResource, Resource, Content, and None elements (more importantly, their…
bwerks
  • 8,651
  • 14
  • 68
  • 100
2
votes
1 answer

Analyse XML file with powershell script

I've got a xml log file. The file looks like this: Warning 0 0 0
movario
  • 23
  • 3
2
votes
1 answer

How to load or read an XML file using ConvertTo-Xml and Select-Xml?

How can I accomplish something like this: PS /home/nicholas/powershell> PS /home/nicholas/powershell> $date=(Get-Date | ConvertTo-Xml) PS /home/nicholas/powershell> PS /home/nicholas/powershell> $date xml …
1
vote
2 answers

How to query XAML file with Powershell's `select-xml` commandlet?

I'm trying to use the select-xml cmdlet in Powershell to query some XAML files in my .NET project. Here's what I've tried: select-xml -content (cat $xaml_file_path) -xpath "//GroupBox" Where $xaml_file_path is simply a string containing the file…
user32882
  • 5,094
  • 5
  • 43
  • 82
1
vote
1 answer

Powershell - XML - How do I extract multiple values from various depths per node family

I've got several million lines of xml to parse. For one application I am looking to extract 3 pieces of data for use in other scripts. The xml looks something like the following (several dozen tags have been removed per grouping) I can change one of…
1
vote
2 answers

Select-Xml returns file name

When parsing my *.csproj using Select-Xml, besides from the expected output i also get a concat of a parameter. What is going on here? $version = Select-Xml -Path $projectFilePath -XPath "/Project/PropertyGroup/Version" Write-Host…
Dbl
  • 5,634
  • 3
  • 41
  • 66
1
vote
1 answer

In Powershell how do I get Select-Xml to search multiple Nodes

So I got to say that I m new to using PowerShell for parsing out XML. With that said, how to do I combine multiple -XPath So that I can finishing building out my expression report. Please let me know, I have tried several combinations and none of…
user2176024
  • 41
  • 1
  • 6
1
vote
2 answers

Trying to get XML element

Here is a piece of XML file from which I want to extract the IP Address (here 172.31.24.8) using PowerShell code:
florian
  • 75
  • 1
  • 4
1
vote
1 answer

Find XML attributes at random

How can I find the 2 attributes $_.CompleteName and $_.Channel at random? + $channel | ? {$liste} | get-random <<<< -min 0 -max $liste.list.groupe.count + CategoryInfo : InvalidArgument: (position:PSObject) [Get-Random ],…
Arnold
  • 49
  • 8
0
votes
1 answer

How to use Select-Xml cmdlet to parse XML from external source?

I'm trying to use Select-Xml to parse XML from SQL server. I have a sql query which gives me an XML string ($Query) and I want to sum up all "Users" values from this XML. My script works perfectly if I use external file for "-Path". But I don't know…
0
votes
1 answer

I can't get my Powershell script to save multiple change to my xml file

I try to change 2 innertext in my xml file but it will only save one of the changes when I run the save command. I can't figure out to save both innertext back to the xml file. Is there anybody that can help me ? Here is my code: Clear-Host $Path =…
0
votes
1 answer

how to use the cmdlet Select-Xml interactive prompt?

How is Select-Xml used as below: PS /home/nicholas/powershell> PS /home/nicholas/powershell> Select-Xml cmdlet Select-Xml at command pipeline position 1 Supply values for the following parameters: Xml[0]: ./bookstore.xml Xml[1]: XPath:…
0
votes
1 answer

How to use Select-Xml in Powershell to print the content of an xml node element?

restricted to xpath or even Select-Xml how else are the book titles printed? PS /home/nicholas/powershell> PS /home/nicholas/powershell> Select-Xml "./bookstore.xml" -XPath "/bookstore/book/title" | foreach {$_.node.InnerXML} Pride And…
1
2