What can I do about “WMIC is deprecated”?

As mentioned in comments, WMIC is utility that acts as interface to communication with WMI. It’s not WMI itself that is being deprecated, but “just” the interface. Since Microsoft is pushing PowerShell, I believe official successor wmic would be PowerShell commandlet Get-WmiObject. How to use this can be found on Microsoft documentation: LINK

[UPDATED] As correctly pointed out within comment, commandlet Get-WmiObject may eventually sunset one day as well and thus its use may not be encouraged to have scripts future proof. Best method to stick with would be Get-CimInstance, which has pretty much the same syntax as Get-WmiObject. See Microsoft documentation: LINK

For your particular case PowerShell alternative would be the following:

wmic memorychip get capacity

Get-CimInstance -ClassName Win32_PhysicalMemory | Select-Object capacity

wmic diskdrive get Status,Model

Get-CimInstance -ClassName Win32_diskdrive | Select-Object status, model

Commands in wmic are usually derived from WMI class names, but it’s not really a rule of thumb. With PowerShell you are accessing WMI by its real class name instead, so you may need to seek for other classes if needed.

As mentioned in comment by Bacon Bits. WMIC aliases to real WMI classes can be obtained by command:

wmic.exe alias list brief

Undisputed advantage to PowerShell over wmic is that output is an object and you can easily continue working with the output, while wmic returns a string only that you eventually need to parse for example if used inside scripts and that brings another benefit of e.g. output formatting – you can easily reformat any output for example to as you mentioned JSON, just pass your command through another pipe into commandlet ConvertTo-Json and you will have your expected output.

Example:

Get-CimInstance -ClassName Win32_diskdrive | select status, model | ConvertTo-JSON

Output:

{
    "status":  "OK",
    "model":  "SAMSUNG MZNTY256HDHP-000L7"
}

Hope this helps

[UPDATE 2.2.2022]
Since this is the first link on Google for this topic that pops out, here’s small update:

Microsoft officially informed about wmic being deprecated in their WMIC documentation

Microsoft page quotes:

The WMI command-line (WMIC) utility is deprecated as of Windows 10, version 21H1, and as of the 21H1 semi-annual channel release of Windows Server. This utility is superseded by Windows PowerShell for WMI. This deprecation applies only to the WMI command-line (WMIC) utility; Windows Management Instrumentation (WMI) itself is not affected.

For the sake of future proof scripts, I would still stick with industrial CIM standard using PowerShell

Leave a Comment