Reputation: 617
I would like to convert the StartupInfo XML log file (Windows 10) to CSV.
C:\Windows\System32\WDI\LogFiles\StartupInfo\<SID>_StartupInfo<NUMBER>.xml
I tried:
[xml]$StartupInfo = Get-Content "C:\Windows\System32\WDI\LogFiles\<SID>_StartupInfo<NUMBER>.xml"
$StartupInfo.StartupData.Process | Export-Csv -Path C:\Users\<USER>\Desktop\StartupInfo.csv -NoTypeInformation
But I have still problems with the columns "CommandLine", "DiskUsage" and "CpuUsage".
Thx for assistance.
Upvotes: 0
Views: 230
Reputation: 1187
I am sure there are more distinguished methods to do this like XSLT transforms. But for this particular type of XML file I think this method works:
$StartupInfo.StartupData.Process | Select-Object Name,PID,StartedInTraceSec,
@{name='CommandLine';Expression={$PSitem.CommandLine.'#cdata-section'}},
@{name='DiskUsage';Expression={$PSItem.DiskUsage.'#text'}},
@{name='CPUUsage';Expression={$PSItem.CPUUsage.'#text'}} |
Export-Csv -Path C:\Users\<USER>\Desktop\StartupInfo.csv -NoTypeInformation
The problem is that XML files aren't flat like CSV files are. If you want an explanation of the technique I used have a look here: https://mcpmag.com/articles/2017/01/19/using-powershell-calculated-properties.aspx
Upvotes: 2