November 2018
Intermediate to advanced
566 pages
17h 15m
English
This is a simple recipe that helps you work with the number of items returned in the output. With Select-Object in PowerShell, we need not loop through output, while simultaneously counting to only get the number of elements that we want. The Select-Object cmdlet has that functionality built in.
The parameter names are self-explanatory, except perhaps the Index parameter, which works exactly how the numbering of array elements works with most programming languages: it starts with zero. Therefore, the fourth element in the array would have an index of 3, and not 4.
The Property and First parameters can be combined together since they both feature in the same parameter set in the help documentation for Select-Object.
Read now
Unlock full access