[QUESTION]Exporting XML node data to CSV

We have to poll every computer for their installed Adobe version (SCCM only reports ‘Acrobat’ because pro or standard is defined by the license key, not the installation) and the keys are stored in an XML file.

I can pull the data but I cannot seem to turn it into a string to export it. The PowerShell window will show the data but in the csv it either has a blank cell or System.XML.XMLElement depending on what I try to produce a string.

$OutputFile = "C:Powershell_ReportsAdobe_Versions" + (get-date -format "-MM-dd-yyyy") + ".csv" $Computer = "RVBIS095742D" [xml]$xml = Get-Content C:PowerShell_Reports*.xml #$XMLPath = "\$ComputerC$ProgramDataregid.1986-12.com.adobe*.swidtag" $swid = @{swid="http://standards.iso.org/iso/19770/-2/2008/schema.xsd"} $Serial = $xml | Select-Xml -Namespace $swid -XPath "//swid:serial_number" | Select-Object -ExpandProperty Node #$Serial | Out-String if ($Serial -like "9707*") { $Version = "Acrobat DC Vol pro" continue } Else { $Version = "Acrobat DC Vol std" } $Serial $License = New-Object PsObject $License | Add-Member noteproperty Computer $Computer $License | Add-Member noteproperty Serial $Serial $License | Add-Member noteproperty Version $Version $License | Select-Object -Property Computer, Serial, Version | export-csv -path $OutputFile -NoTypeInformation -Append 

Yes, I know there are easier short-hand ways to make a new ps-object… I have a template of code that I just quick copy-paste and change..

There is code in there commented out for when I start polling the rest of the computers, currently it is looking at a copy of the .swidtag (xml file) on my local machine just for testing. Same with the $Serial output to make sure it is pulling the info..

submitted by /u/darkapollo1982
[link] [comments]

Leave a Reply