Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to parse the output of the Windows command `wmic` using PowerShell

I am trying to parse the output of:

wmic copmutersystem

and

net.exe config workstation

using PowerShell to get an object as Key/Value pair and/or convert it to JSON String.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I know there is a PowerShell equivalent command:

Get-CimInstance  -Class Win32_computersystem

But the ask here is to figure out how to use PowerShell to parse a similar output for wmic CMD line.

>Solution :

Wmic can output csv or xml, but obviously get-wmiobject or get-ciminstance is preferred. You just need to find the class names instead of the aliases. The creator of wmic and powershell is the same.

wmic computersystem list /format:csv | convertfrom-csv | select model

Model
-----
OptiPlex 7490 AIO

List wmic class aliases:

wmic alias list brief

For example:

ComputerSystem                                   Select * from Win32_ComputerSystem
get-ciminstance win32_computersystem
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading