Using flow control statements
Flow control statements are used in the shell to run one or more commands based on the result of a conditional test. You can use the If
statement to test one or more conditional statements, and you can also use switch
statements when multiple If
statements would otherwise be required. This recipe will show you how to control the flow of execution that your scripts will use in the shell.
How to do it...
Let's store the status of a database called DB1
in a variable that can be used to perform some conditional checks:
$DB1 = Get-MailboxDatabase DB1 -Status
When using an If
statement, you use the If
keyword followed by an expression enclosed in parenthesis that performs a conditional check. If the expression is evaluated ...
Get Microsoft Exchange 2010 PowerShell Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.