PowerShell Construct Operators

PowerShell has powerful loops and construct operators.

If then loop:

if ($x -gt 2) {

#type your code

}

If then else loop:

if ($x -gt 2) {

#type your code

} elseif ($x -lt 2) {

#type your code

} else {

#type your code

}

Switch look (Select case in VB)

switch ($x) {

2 {

#type your code

break

}

3 {

#type your code

break

}

default {

#type your code

break

}

}

For Loop

Explaination: execute the code while the variable value is less than 5.

for ($b=0; $b -lt 5; $b++) {

#type your code

}

Do while loop

do {

#type your code

} while ($a -lt 5)

While loop

while ($a -lt 5)

#type your code

}

Do Until loop

do {

#type your code

} until ($a -lt 5)

Foreach loop

foreach ($item in $items) {

#type your code

}

Subscribe For Latest Updates

Sign up for best of digital marketing, livestream and technology opinions on what matters to you.

Invalid email address
We promise not to spam you. You can unsubscribe at any time.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: