PowerShell 2.0: One Cmdlet at a Time 90 Remove-WMIObject

Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Remove-WMIObject cmdlet.

What can I do with it?

Remove an instance of a WMI class.


Start Windows Calcultor. Retrieve the running process and terminate it.

calc Get-WmiObject Win32_Process -Filter “name=‘calc.exe’” | Remove-WmiObject

How could I have done this in PowerShell 1.0?

In the above example you could have called the Terminate method on the object returned in the WMI query. One of the advantages though of Remove-WmiObject is the possibility to use the pipeline.

(Get-WmiObject Win32_Process -Filter “name=‘calc.exe’”).Terminate()

1000 things 1% better