O'Reilly logo

Windows PowerShell™ 3.0 Step by Step by Ed Wilson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Executing instance methods: step-by-step exercises

In this exercise, you will use the terminate instance method from the WIN32_Process WMI class. This provides practice calling WMI instance methods. In the next exercise, you will practice calling static class methods.

Stopping several instances of a process using WMI

  1. Log on to your computer with a user account that does not have administrator rights.

  2. Open the Windows PowerShell console.

  3. Start five copies of Notepad. The command appears here:

    1..5 | % {notepad}
  4. Use the Get-WmiObject cmdlet to retrieve all instances of the notepad.exe process. The command appears here:

    gwmi win32_process -Filter "name = 'notepad.exe'"
  5. Now pipeline the resulting objects to the Remove-WmiObject cmdlet.

    gwmi win32_process ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required