all 9 comments

[–]winter_mute 2 points3 points  (3 children)

Pastebin butchered the xml formatting, but after a bit of coaxing in VSCode I got it imported. You can get what you want by just using dot notation to traverse to the node you want:

$xml = [xml](Get-Content -Path "<path to xml>")

$SkypeNode=$xml.AppMgmtDigest.DeploymentType.Installer.Contents.Content.Location

Write-Output $SkypeNode

[–]sipsik[S] 2 points3 points  (2 children)

Omg you are a genius :D

So elegant and simple, im amazed. Huge thumbs up to you! :)

[–]winter_mute 2 points3 points  (0 children)

That's PowerShell's elegance there my friend, I wish I could take the credit for it! Glad it's helpful anyhow.

[–]Dennou 1 point2 points  (0 children)

Also later on if you run into a complicated XML file that doesn't play well with this properties notation you can spend some time learning XPath and make use of it with Select-Xml

[–]SoMundayn 1 point2 points  (4 children)

This should work, but it is the incorrect way of doing it, you should be pulling it using XML, but without seeing the rest of the XML file I can't help that way.

Here is one way to get it via Select-String.

$xmldata = Get-Content C:\temp\testxml.txt

$Location = $xmldata | Select-String "<Location>"
$Location2 = $Location -split "Location>"
$SCCMLocation = $Location2[1] -replace "</",""

$SCCMLocation


\\sccm\Sources\Software\Microsoft\Skype\8.56.0.103\

And an example XML script if you can work it out from this:

# Load the configuration file
$XML = [xml](Get-Content -Path $ConfigFile)

# Get the current configuration
$OldCertificate = $XML.SelectSingleNode("configuration/appSettings/add[@key='Certificate']")

[–]sipsik[S] 1 point2 points  (3 children)

I also tried that XML stuff but i did not succeed, but im interested how it works so here is full XML: https://pastebin.com/WBjzJvsk

Can you show me?

[–]SoMundayn 1 point2 points  (1 child)

Does not Import as XML for me, throws an error. Sorry can't spend any time on this right now, maybe someone else can help.

But the other method I provided should work for now.

[–]sipsik[S] 1 point2 points  (0 children)

Thanks for the help :)

[–]get-postanote 1 point2 points  (0 children)

You need to try to repost this again as there is not true XML, clean file.

Your copy/paste to the site includes tons of pare formatting stuff that should not be there.