February 2019
Intermediate to advanced
626 pages
15h 51m
English
The remainder operator returns the remainder of the whole-number (integer) division. For example, the result of the following operation is 1:
3 % 2
The remainder operator can also be used for alternation. That is, performing an action on every second, third, fourth, and so on iteration of a loop.
1..100 | Where-Object { $_ % 5 -eq 0 } | ForEach-Object { Write-Host $_}
The value will show 5, 10, 15, 20, and so on. Each of those values will have a remainder of when divided by 5.
Read now
Unlock full access