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
Name : Microsoft Windows 11 Enterprise Insider Preview
Version : 10.0.22463.1000
Path : AD Path
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.
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:
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.
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.
Please sign in to leave a comment.