Entries Tagged as 'PowerShell'

Powershell the switch statement pt 2.

The string value specified in the switch statement’s script block has to exactly match a condition for that condition to equal true. Despite it being unnecessary for exact matches, this would be the same as using the -exact option in a switch statement. There are other options available for use such as -wildcard which lets you use wildcards, and -regex which uses regular expressions. lets look at an example;

[Read more →]

SocialTwist Tell-a-Friend

PowerShell Tutorial the switch statement part 1.

PowerShell’s switch statement is similar to an if statement though easier to implement when you want to evaluate numerous conditions. You can use the switch statement to automate tasks such as retrieving System event log entries and performing actions based on the type of entry, and or moving and deleting files based on their file names.

[Read more →]

SocialTwist Tell-a-Friend

PowerShell tutorial. The While Statement

Similarly to the for statement, the while statement is another type of loop that parses through a collection. The while statement also includes a conditional code block and a script block and continues for so long as the conditional code block equal true.

[Read more →]

SocialTwist Tell-a-Friend

Powershell tutorial. The For Statement

This week’s lesson builds on last weeks tutorial but introduces the For statement. The For statement uses a counting loop that processes and continues through a collection as long as the condition equals true. Similar to If statements, the for statement includes a conditional code block and a script block. However you will see that the conditional code block is far more complex.

[Read more →]

SocialTwist Tell-a-Friend

Windows PowerShell the if statement

There are several ways to control the flow of code within your powershell scripts. The if, for, and while statements are used to define conditions and the actions to happen when the conditions are met. In this blog I’ll focus specifically on the if statement.

[Read more →]

SocialTwist Tell-a-Friend