Parse PDQ Inventory CLI Output data
Trying to parse data to collect info via code from inventory directly.
Basically from PowerShell I save the output
$compdata = PDQInventory GetComputer $compname
output is formatted like this (I shortened it a bit)
Name : compname
ID : number
Operating System
Name : Microsoft Windows 11 Enterprise Insider Preview
Version : 10.0.22463.1000
Active Directory
Path : AD Path
System
Manufacturer : Dell Inc.
Model : Model
How do I go about converting this into a format that I can parse through and grab the name or ip like json?
I've tried to pipe ConvertTo-Json but the output I get is not as expected and I can't seem to parse it properly.
0
Comments
Unfortunately, that command was never built to be computer parsable. You can try to use -split and Select-String, but it's likely to be error prone. I have a couple of alternatives:
Read the warning, then:
Colby Bouma
Thanks Colby!
I went through the module but I'm notorious for locking our database up when using anything with a hint of SQL so I ended up using code from here for the time being.
https://stackoverflow.com/questions/69397291/powershell-convert-data-to-json-for-parsing
code:
At the end of it I convert back from json and remove the file made before.
Then i'm able to parse through the data through the $parseObj variable.