7 One-click Exchange account fix

 

This chapter covers:

  • How to build a function that we can utilize multiple times in our script.
  • A new type of loop: the Do-Until loop perfect for status updates.
  • Built in Exchange functions that lets us create, remove, backup and import user mailboxes.

At the time of writing this, email has been and is the king of internal communication. With the rise of social media and the ever-present text and phone communication options email has lost some of its ride or die status; yet it’s clear that this form of communication is not going anywhere soon. As a system administrator it’s likely you’ll be tasked with some common Exchange related tasks.

Currently there are three main types of Exchange solutions offered to your typical enterprise.

  • On-Prem
  • As a Service
  • Hybrid

One thing they all have in common? You, as a system administrator, are going to be interfacing with them. Even with your email as a service and hybrid solutions utilizing Office 365, management of your email systems is up to you.

Most system administration of Exchange services is done either through ECP (Exchange Control Panel) or the EAC (Exchange Admin Center), but there is a third option: PowerShell.

7.1 Functions

7.2 More Looping

7.2.1 Foreach Loop

7.2.2 Do-Until Loop

7.3 Select-Object

7.4 Exchange Specific Cmdlets

7.4.1 New-MailboxExportRequest

7.4.2 Get-MailboxExportRequest

7.4.3 Disable-Mailbox

7.4.4 Enable-Mailbox

7.4.5 New-MailboxImportRequest

7.4.6 Get-MailboxImportRequest

7.5 Putting it all together

7.5.1 Create a Function

7.5.2 Get User Information

7.5.3 Backup User’s Mailbox

7.5.4 Wait for Backup to Complete

7.5.5 Disable Bad Email Box

7.5.6 Enable New Mailbox

7.5.7 Import Backup from Old Mailbox

7.5.8 Wait for Import to Complete