In this tutorial, I will create a simple program with Power Shell to print the odd numbers ranging from 1 to 10 with the help of the ‘foreach’ loop.
The command is as follows:-
foreach ($i in 1..10) { if ($i % 2 -eq 0) {continue} $i }
As you can see that the if condition statement will filter out all the even numbers and only allow the odd numbers to be printed out on the Power Shell screen!
1 3 5 7 9
Very simple and easy indeed!