Powershell - Select-Object Cmdlet



Cmdlet

Select-Object cmdlet is used to select object or its properties.

In these example, we're see the Select-Object cmdlet in action.

Example 1

In this example, we'll create objects using Process properties.

Get-Process | Select-Object -Property ProcessName, Id, WS -Last 5

Output

You can see the following output.

 ProcessName                                 Id                            WS
-----------                                  --                            --
UNS                                        2624                      10301440
wininit                                     624                       4935680
winlogon                                    552                       7774208
WLTRYSVC                                   3080                       3608576
WmiPrvSE                                   1620                      11870208

Example 2

In this example, we'll select unique values of an array.

"a","b","c","a","a","a" | Select-Object -Unique

Output

You can see the following output.

a
b
c
powershell_advanced_cmdlets.htm
Advertisements