Posts

Showing posts from October, 2018

How to Configure Message Forwarding on a Mailbox Level

Image
The Set-Mailbox cmdlet has two parameters to configure forwarding for a mailbox: ForwardingAddress and ForwardingSmtpAddress. Those two parameters serve the same puspose but in two different ways. There is also a third parameter called DeliverToMailboxAndForward that when set will leave a copy of the message on the mailbox. The "ForwardingAddress" accepts RecipientIdParameter input which means that you have to use the identity of an existing object on your organization such as another mailbox or a mail contact. The "ForwardingSmtpAddress" accepts input in a proxy address format such as plain old email addresses. Although this is pretty straight forward, there's a catch you need to be aware of. This will only work if the remote domain of the recipient is configured to allow message forwarding. Let me elaborate. There's a thing on Exchange, called Remote Domains . Those are used in order to define settings for the communication between your Exchange ser...

Catching Exceptions in PowerShell

Things can go wrong even on the simplest tasks. A network failure, a fail over, inadequate permissions and many other factors can make your scripts and functions fail. Let's see how we can control failure! There are two statements in PowerShell that help to control failed commands. These are "try" and "catch". Their usage is pretty straightforward, you wrap the commands that might fail in a try block and specify the actions to be executed upon the failure in the catch block. Below is a simple try/catch block in a function: try { Remove-Item -Path myfile.txt -ErrorAction Stop } catch { Write-Host "Cound not remove item" } Here, if the Remove-Item command fails, the string "Could not remove item" will be written on the console. A couple of things to notice here. First, the -ErrorAction preference is set to Stop for the command since this way the command will generate and exception instead of just writing to the error s...