PowerShell for Windows Admins

Feb 27 2014   4:20PM GMT

I’m afraid you can’t do that anymore

Richard Siddaway Richard Siddaway Profile: Richard Siddaway


In PowerShell 1.0 you could do this:


$proc = Get-WmiObject -Class Win32_Process -Filter “Name=’notepad.exe'”


To access the methods of the WMI class you had to get a variable representing the instance and call the method. This technique still works in PowerShell 4.0

When the CIM cmdlets were introduced in PowerShell 3.0 people assumed that they worked the same:

£> notepad

£> $proc = Get-CimInstance -ClassName Win32_Process -Filter “Name=’notepad.exe'”

£> $proc.Terminate()

Method invocation failed because [Microsoft.Management.Infrastructure.CimInstance] does not contain a method named


At line:1 char:1

+ $proc.Terminate()

+ ~~~~~~~~~~~~~~~~~

+ CategoryInfo : InvalidOperation: (Terminate:String) [], RuntimeException

+ FullyQualifiedErrorId : MethodNotFound

The CIM cmdlets retrun inert objects – NO METHODS – so you can’t do that.

The correct way to use the CIM cmdlets is:

Get-CimInstance -ClassName Win32_Process -Filter “Name=’notepad.exe'” | Invoke-CimMethod -MethodName Terminate

 Comment on this Post

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: