I’m a powershell newb. There I said it. Now let me learn. Here’s what I created after some google searches.
- Go through all files in a directory
Get-ChildItem . -r -file
- Filter on xml files
Where { $_.Extension -EQ '.xml'}
- Take only the files that match a XPath
Select-Xml -XPath "XPATH_HERE"
- Copy the file to a directory
Copy-item -Destination DESTINATION_DIR_HERE
this takes the Path from the Get-ChildItem, make sure to use -Destination to avoid parameter exception as described here
I think this can be added to the Get-ChildItem command, have fun optimizing this 🙂
you can test the xpath with online tools like this one
Complete line with pipes
Get-ChildItem . -r -file | Where { $_.Extension -EQ '.xml'} | Select-Xml -XPath "XPATH_HERE" | Copy-item -Destination DESTINATION_DIR_HERE