Run a PowerShell Command

1. Problem

You want to run a PowerShell command.

2. Solution

To run a PowerShell command, type its name at the command prompt. For example:

        PS >Get-Process

        Handles  NPM(K)    PM(K)    WS(K)   VM(M)  CPU(s)    Id ProcessName
        -------  ------    -----    -----   -----  ------    -- -----------
            133       5    11760     7668      46          1112 audiodg
            184       5    33248      508      93          1692 avgamsvr
            143       7    31852      984      97          1788 avgemc


3. Discussion

The Get-Process command is an example of a native PowerShell command, called a cmdlet. As compared to traditional commands, cmdlets provide significant benefits to both administrators and developers:

· They share a common and regular command-line syntax.

· They support rich pipeline scenarios (using the output of one command as the input of another).

· They produce easily manageable object-based output, rather than error-prone plain text output.

Because the Get-Process cmdlet generates rich object-based output, you can use its output for many process-related tasks.

The Get-Process cmdlet is just one of the many that PowerShell supports. See Section 1.4, “Find a Command to Accomplish a Task” to learn techniques for finding additional commands that PowerShell supports.

For more information about working with classes from the .NET Framework, see Section 3.4, “Work with .NET Objects.”

4. See Also

· Section 1.4, “Find a Command to Accomplish a Task”

· Section 3.4, “Work with .NET Objects”

Tags: , , ,