Get-WmiObject Is Not Recognized in PowerShell 7? Why and How I Fixed It

By Ahmet Tolga KAYA 9 min read
Get-WmiObject Is Not Recognized in PowerShell 7? Why and How I Fixed It

Quick answer: Get-WmiObject is not recognized in PowerShell 7 because the WMI v1 cmdlets (Get-WmiObject, Invoke-WmiMethod, Set-WmiInstance, Remove-WmiObject, Register-WmiEvent) were removed when PowerShell moved to .NET Core. Replace them with the CIM cmdlets such as Get-CimInstance and Invoke-CimMethod, or run the old script in Windows PowerShell 5.1 for now.

Get-WmiObject is not recognized is usually the first thing an old inventory or monitoring script prints when someone runs it in PowerShell 7 instead of the built-in Windows PowerShell. I hit it the classic way: a script that worked for years in powershell.exe failed the moment it ran in pwsh.exe, from a scheduled task that had been switched to the new shell. Nothing is broken on the machine. WMI itself is fine; only the old cmdlets are gone. Below is why that happens and the order I use to move a script to the CIM cmdlets without breaking its output.

Get-WmiObject is not recognized in PowerShell 7: replacing the WMI cmdlets with Get-CimInstance and Invoke-CimMethod

What the Get-WmiObject Is Not Recognized Error Looks Like

In PowerShell 7.4 on Windows, this is the exact text you get:

Get-WmiObject: The term 'Get-WmiObject' is not recognized as a name of a cmdlet,
function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path
is correct and try again.Code language: JavaScript (javascript)
Get-WmiObject is not recognized error in a PowerShell 7.4 console while running an older script

The message is the generic “command not found” error, which is why it sends people in the wrong direction. You can reinstall modules, repair WMI with winmgmt, or rebuild the repository and the error will stay, because the cmdlet simply does not exist in that PowerShell edition. Before touching anything, confirm which shell is running the script:

$PSVersionTable.PSEdition      # Core = PowerShell 7, Desktop = Windows PowerShell 5.1
$PSVersionTable.PSVersion
Get-Command Get-WmiObject -ErrorAction SilentlyContinue   # nothing returned in PowerShell 7Code language: PHP (php)

Why Is Get-WmiObject Not Recognized in PowerShell 7?

The reason Get-WmiObject is not recognized is documented. Microsoft’s differences between Windows PowerShell 5.1 and PowerShell 7 page lists the WMI v1 cmdlets among the commands removed from PowerShell: Register-WmiEvent, Set-WmiInstance, Invoke-WmiMethod, Get-WmiObject and Remove-WmiObject. The same page says the CimCmdlets module (also called WMI v2) performs the same function with a redesigned syntax. The WMI cmdlets depended on Windows-only .NET Framework pieces, and PowerShell 6 and later run on .NET Core, so they were left behind.

This is not new. The PSScriptAnalyzer AvoidUsingWMICmdlet rule has warned since PowerShell 3.0 that you should use CIM cmdlets instead, and the PowerShell 101 chapter on WMI calls the WMI cmdlets deprecated and not available in PowerShell 6+. Checked against the current documentation, the PowerShell 7 WMI cmdlets December 2026 picture is the same as it was in PowerShell 6: all five are still absent, and Windows PowerShell 5.1 still ships with Windows and still runs them.

One thing that surprised me in my own lab: the [wmi], [wmiclass] and [wmisearcher] type accelerators still work in PowerShell 7.4 on Windows. A script that only uses [wmisearcher]"SELECT ..." may run fine while the one next to it fails on Get-WmiObject. So a Get-WmiObject is not recognized error does not mean every WMI line in the script is broken; fix the cmdlets first.

How to Replace Get-WmiObject in PowerShell 7

This is the mapping I keep open while converting a script. The first five rows come from Microsoft’s PSScriptAnalyzer rule; the notes are the details that actually broke things for me:

WMI cmdlet (removed)CIM replacementWhat changes
Get-WmiObjectGet-CimInstance-Class becomes -ClassName; -Filter and -Query work the same
Invoke-WmiMethodInvoke-CimMethodArguments go in a hashtable with -Arguments, not a positional -ArgumentList
Set-WmiInstanceSet-CimInstancePass changed values with -Property @{...}
Remove-WmiObjectRemove-CimInstancePipe the instance from Get-CimInstance
Register-WmiEventRegister-CimIndicationEventSame WQL event queries
$obj.Method() on a WMI objectInvoke-CimMethod -InputObjectCIM instances carry no WMI methods
$wmi.ConvertToDateTime()Nothing neededCIM returns DateTime values directly
-ComputerName over DCOM-ComputerName or -CimSessionCIM uses WSMan (WinRM) by default

For most read-only scripts the fix is a find-and-replace plus one parameter name. This is how I replace Get-WmiObject in PowerShell 7 for a typical disk query:

# Windows PowerShell 5.1 only
Get-WmiObject -Class Win32_LogicalDisk -Filter "DriveType=3"

# Works in 5.1 and 7.x
Get-CimInstance -ClassName Win32_LogicalDisk -Filter "DriveType=3"
Get-CimInstance -Query "SELECT * FROM Win32_Service WHERE StartMode='Auto' AND State='Stopped'"
Get-CimInstance -Namespace root/cimv2 -ClassName Win32_ComputerSystem

To find every line that needs attention in a folder of scripts, I search for all five cmdlet names at once:

Get-ChildItem .\Scripts -Filter *.ps1 -Recurse |
    Select-String -Pattern 'Get-WmiObject|Invoke-WmiMethod|Set-WmiInstance|Remove-WmiObject|Register-WmiEvent|\bgwmi\b' |
    Select-Object Path, LineNumber, LineCode language: JavaScript (javascript)

Do not forget the gwmi alias. Old one-liners use it a lot, and Get-WmiObject is not recognized shows up for the alias too, because the alias disappeared with the cmdlet.

Get-WmiObject is not recognized fix order: confirm, swap to Get-CimInstance, fix methods with Invoke-CimMethod, test remote

Fixing Method Calls with Invoke-CimMethod

Swapping the cmdlet clears the Get-WmiObject is not recognized error, but method calls are where most conversions break. Objects returned by Get-WmiObject carried live methods, so scripts did things like (Get-WmiObject ...).Terminate(). Objects returned by Get-CimInstance do not have those methods, so you call them with Invoke-CimMethod instead. These are the patterns from the Invoke-CimMethod documentation, which I ran in PowerShell 7.4 against a throwaway process:

# Instance method: pipe the instance in
Get-CimInstance -ClassName Win32_Process -Filter "Name='notepad.exe'" |
    Invoke-CimMethod -MethodName Terminate

# Static method: arguments in a hashtable
$r = Invoke-CimMethod -ClassName Win32_Process -MethodName Create -Arguments @{ CommandLine = 'notepad.exe' }
$r.ReturnValue   # 0 = success
$r.ProcessIdCode language: PHP (php)

Check ReturnValue every time. WMI methods report failure through that number, not through a PowerShell error, so a failed call can look successful if you ignore it.

Changing properties follows the same idea. The Set-CimInstance documentation uses a test environment variable as its example:

Get-CimInstance -Query 'SELECT * FROM Win32_Environment WHERE Name="testvar"' |
    Set-CimInstance -Property @{ VariableValue = 'somevalue' } -PassThruCode language: JavaScript (javascript)

The Date Format Trap

This one cost me a report full of wrong uptime values after the Get-WmiObject is not recognized error was already gone. In Windows PowerShell 5.1, Get-WmiObject returns date properties as DMTF strings, so LastBootUpTime looks like 20261024154123.500000+180 and scripts call ConvertToDateTime() on it. Get-CimInstance already returns a System.DateTime. If you keep the conversion line after switching cmdlets, the script fails, because the CIM object has no such method.

# Old (5.1)
$os = Get-WmiObject Win32_OperatingSystem
$boot = $os.ConvertToDateTime($os.LastBootUpTime)

# New (5.1 and 7.x)
$os = Get-CimInstance -ClassName Win32_OperatingSystem
$uptime = (Get-Date) - $os.LastBootUpTime
'{0:%d} days {0:hh\:mm} hours' -f $uptimeCode language: PHP (php)

Querying Remote Servers with CIM Sessions

If the Get-WmiObject is not recognized error came from a remote inventory script, the second difference matters: the protocol. The WMI cmdlets talked to remote machines over DCOM. Get-CimInstance uses WSMan (WinRM) by default, as described in the PowerShell 101 WMI chapter. If WinRM is enabled on the target, the simplest change works. Get-CimInstance has no -Credential parameter, so for alternate credentials you create a CIM session first:

Get-CimInstance -ComputerName SRV01 -ClassName Win32_OperatingSystem

$cred = Get-Credential
$s = New-CimSession -ComputerName SRV01, SRV02 -Credential $cred
Get-CimInstance -CimSession $s -ClassName Win32_Service -Filter "Name='Spooler'"
Remove-CimSession $sCode language: PHP (php)

For older servers where WinRM is not configured, New-CimSessionOption can build a DCOM session, which behaves like the old cmdlets on the network:

$opt = New-CimSessionOption -Protocol Dcom
$s = New-CimSession -ComputerName OLDSRV01 -SessionOption $opt -Credential $cred
Get-CimInstance -CimSession $s -ClassName Win32_BIOSCode language: PHP (php)

A tip from experience: run Test-WSMan -ComputerName SRV01 before blaming the script. If that fails, the problem is WinRM or the firewall, not the conversion.

When You Cannot Rewrite the Script Today

Sometimes the script belongs to a vendor, or the change window is tomorrow. You have three honest ways around Get-WmiObject is not recognized, in the order I prefer them:

  • Run it in Windows PowerShell 5.1. Point the scheduled task or launcher at powershell.exe instead of pwsh.exe. Nothing else changes.
  • Call 5.1 from PowerShell 7 for one block. Passing a script block to powershell.exe returns the results as deserialized objects, which is fine for reporting.
  • Use the Windows PowerShell compatibility feature. Import-Module Microsoft.PowerShell.Management -UseWindowsPowerShell made Get-WmiObject available again in my PowerShell 7.4 test, but it printed a long proxy warning and every result was deserialized. The compatibility documentation explains that it works through implicit remoting, so treat it as a stopgap.
$ps51 = "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell.exe"
$bios = & $ps51 -NoProfile -Command { Get-WmiObject Win32_BIOS | Select-Object Manufacturer, SMBIOSBIOSVersion }
$bios.ManufacturerCode language: PHP (php)

Deserialized objects have properties but no methods, so anything that calls .Terminate() or .Put() still needs the real conversion.

How Do I Verify the Fix?

Run the converted script in both shells. If you converted to the CIM cmdlets, it should produce the same data in powershell.exe and pwsh.exe, and the Get-WmiObject is not recognized error should be gone:

pwsh -NoProfile -File .\Get-Inventory.ps1
powershell.exe -NoProfile -File .\Get-Inventory.ps1

# Optional: let PSScriptAnalyzer find leftovers
Invoke-ScriptAnalyzer -Path .\Get-Inventory.ps1 -IncludeRule PSAvoidUsingWMICmdletCode language: CSS (css)
Get-WmiObject is not recognized fixed: Get-CimInstance returns disk and boot time data in PowerShell 7

Compare a few values by hand, especially dates and anything numeric that used to be converted. Once Get-WmiObject is not recognized no longer appears, keep it that way. The PSScriptAnalyzer rule is a good gate for a script repository: it flags any WMI cmdlet that slips back in during a later edit.

Common Mistakes I See

  • Repairing or resetting the WMI repository. When Get-WmiObject is not recognized, WMI is not the problem, and a repository reset can break other software.
  • Replacing the cmdlet but leaving .ConvertToDateTime() or instance method calls in place.
  • Assuming Get-CimInstance works remotely over DCOM by default; it uses WinRM unless you build a DCOM session.

Read more: Running Scripts Is Disabled on This System: PowerShell Execution Policy Fix

Read more: PackageManagement Is Currently in Use: Fixing Install-Module

Read more: AD Drive Does Not Exist in PowerShell: Fixing Get-Acl Errors

Get-WmiObject Is Not Recognized: FAQ

Why is Get-WmiObject not recognized in PowerShell 7?

The WMI v1 cmdlets, including Get-WmiObject, Invoke-WmiMethod and Set-WmiInstance, were removed when PowerShell moved to .NET Core in version 6. They still exist in Windows PowerShell 5.1. Use the CIM cmdlets such as Get-CimInstance instead.

What is the replacement for Get-WmiObject?

Get-CimInstance. Use -ClassName instead of -Class; -Filter, -Query and -Namespace work the same way. It works in both Windows PowerShell 5.1 and PowerShell 7.

How do I call WMI methods without Invoke-WmiMethod?

Use Invoke-CimMethod. For an instance method, pipe the object from Get-CimInstance into Invoke-CimMethod -MethodName. For a static method, pass -ClassName and the arguments as a hashtable with -Arguments, then check ReturnValue.

Can I install Get-WmiObject in PowerShell 7?

There is no supported way to add it to PowerShell 7 natively. You can run the script in Windows PowerShell 5.1, or use Import-Module Microsoft.PowerShell.Management -UseWindowsPowerShell as a temporary workaround that returns deserialized objects.

Does Get-CimInstance work on remote computers without WinRM?

Not by default, because it uses WSMan. Create a session with New-CimSessionOption -Protocol Dcom and New-CimSession, then pass it to Get-CimInstance with the -CimSession parameter.

References

Microsoft Learn: Differences between Windows PowerShell 5.1 and PowerShell 7.x

Microsoft Learn: PSScriptAnalyzer rule AvoidUsingWMICmdlet

Microsoft Learn: Chapter 7 – Working with WMI

Microsoft Learn: Get-CimInstance

Microsoft Learn: Invoke-CimMethod

Microsoft Learn: New-CimSessionOption

Microsoft Learn: about_Windows_PowerShell_Compatibility

Ahmet Tolga KAYA

Systems Engineer and Technical Writer focused on Windows, Microsoft technologies, infrastructure, cybersecurity, automation, and platform reliability.