Chapter 3
Activities
- We can combine
-first
,-last
, and-skip
to do this, like so:1,2,3,4,5,6,7,8 | Select-Object -last 2 -First 3 -skip 1
If we read the help file carefully, we will see that the
-skip
parameter will skip from the start, unless it is combined with-last
. However, it is not positional, so if we specify both the-first
and-last
parameters,-skip
will always skip from the start of the array; it doesn’t matter where we put it in the cmdlet:
Figure A.3 – Output when we use first, last, and skip
- This is because
-contains
doesn’t support wildcards. The value must match exactly, except that it is not case sensitive. Get-Command -ParameterName filter
will do this for us. If you run it, you will see that there are lots of them. Most of them make use of the samefilter
block syntax we’ve been looking at in this chapter.
Exercises
- Get-Date | Select-Object DayOfWeek
First, we need to know...