PowerShell Daily Dose: Get-Process

Get-Process cmdlet gets all the currently running processes on your machine. If you want to see the instances of a particular application, then you can specify the application name.

This gets you all the processes:


This gets you all the instances of Google Chrome web browser:

Get-Process Chrome

And the output will be like this:

Handles  NPM(K)  PM(K)   WS(K)  VM(M)    CPU(s)  Id       ProcessName
-------  ------  -----   -----  -----    ------  --        -----------
 142        19   27828   34220   206     1.05     2544   chrome
 142        19   28268   33976   217     1.33     2924   chrome

You can also use wildcards in application name. For example, if you want to see all the processes that have “sql” in their names, then you can do this:

PS C:\Learn> get-process *sql*

Handles NPM(K) PM(K)  WS(K)  VM(M) CPU(s) Id ProcessName
------- ------ -----  -----  ----- ------ -- -----------
 288     41     19152   5880 512    1.20 5668 SQLAGENT
 473     30     14572  11448 103    2.31 4232 sqlbrowser
 749    178    513208 322264 143   13.28 3028 sqlservr
  91      9      3408   7596  41    0.16 4260 sqlwriter

You can also specify other parameters like process id, handle etc.

For more information on syntax and usage, please refer to the documentation here.

PowerShell Daily Dose: Get-Content

Get-Content gets the contents of the specified file. A simple usage example:

PS C:\test> Get-Content ps.txt
some random
text for
testing powershell
get-content cmdlet...

Note that you don’t have to type the whole cmdlet; you can use one of the aliases of this cmdlet: cat, gc or type.

This command returns a collection of objects. Each object represents a line of content in the file. You will start realizing the potential of this command as you learn more commands. For example, you can pipe the output of this command to a looping command like ForEach-Object.

There are several different options that you can pass on to the command. For example you can specify the number of lines to read, pass credentials to use, filter strings, include and exclude strings and many more. For more detailed info please check the get-content help page.