One of the great things about Exchange Server is the ability to use PowerShell for a wide variety of administration tasks. And one of the great strengths of PowerShell is the ability to use scripts to automate complex or repetitive tasks to save time, save effort, and avoid errors.
The Exchange Server community has a long history of sharing PowerShell scripts that they have developed so that everyone can benefit from them. Here's a selection of PowerShell scripts that I think should be in any toolkit.
Note: many of these scripts are developed by individuals in their personal time. If you like a script please let the author know by rating it on the TechNet Script Gallery or leaving a comment on their blog. Similarly, if you find a bug with a script the authors are usually very happy to receive bug reports from the community so that they can fix them.
Exchange Environment Reports
Exchange MVP Steve Goodman wrote this PowerShell script to generate a HTML report that provides an overview of your Exchange environment. I use this script as my first look at any Exchange organization when I am doing support or planning a migration.
Exchange V15 (2013/2016) Unattended Install Script
Installing the Exchange pre-requisites and building Exchange servers from scratch is a good skill to learn, but after you've learned it you will want to automate as much of it as possible. Exchange MVP Michel de Rooij has done just that, maintaining this PowerShell script to install pre-requisites and perform unattended installs of Exchange Server 2013 and 2016.
Exchange Log Level GUI Script
During a troubleshooting exercise there's a good chance you'll increase the diagnostic logging level for several Exchange Server components. Zachary Loeber has put together a PowerShell script that launches a GUI to let you configure the diagnostic levels on your servers.
Exchange Mailbox Size and Statistics Report
One of the first PowerShell scripts I wrote many years ago, and have kept updated every since. This script generates a CSV file containing lots of useful stats and information about the mailboxes in your Exchange organization. I use this script when capacity planning and also during migration projects.
Health Report for Exchange Server 2010/2013 Environments
This PowerShell script can provide you with a health check report for an Exchange Server 2010 or 2013 environment, highlighting issues such as stopped services, unhealthy database replication, or transport queues not processing messages. Run it as a scheduled task for a quick morning health check delivered straight to your inbox.
Analyze Move Request Performance
During a migration it's often important to keep an eye on the performance of your migration batches. The Microsoft Exchange Team published this PowerShell script to help you analyze move request performance statistics to identify any causes of poor performance.
Monitor Exchange Server Backups
I've used this script as a scheduled daily report in every operations role where I was supporting Exchange Server 2007 or later, as well as during every migration project. This script helps you keep an eye on the backup time stamps of Exchange databases to ensure that backups are actually running and completing successfully. Don't trust your backup software to always tell you the truth, and don't trust others to always add new databases to the backup schedule when they're created!
Compress and Archive IIS Logs
Keep your disk space utilization under control by regularly compressing and archiving the IIS logs on your Exchange Servers.
Purge Exchange Server 2013 Log Files
If you'd prefer to just purge the log files completely try Thomas Stensitzki's update to Brian C Reid's script that removes not only the IIS logs but also the performance and diagnostic logs that Exchange Server 2013 generates automatically.
Check Your RBAC Role Group Membership
Keeping a close eye on role group membership in an Exchange environment is important to maintain least-privilege access for the different teams in your organization. This PowerShell script will export the membership of each role group so you can verify who has access to what, and extra info such as whether they have any passwords that haven't been changed in a long time.
Generate File-System Antivirus Exclusions List for Exchange Server 2013
Antivirus software is a leading cause of unplanned database failovers in an Exchange environment. This PowerShell script generates the list of file, folder and process exclusions to add to the antivirus configuration on an Exchange server, based on Microsoft's recommended practices.
Audit RDP Connections for your Servers
Ever wanted to know who has been logging on to your Exchange servers using RDP? Exchange MVP Mike Crowley has published this script so you can run a report any time you like.
Check your Exchange Server SSL Certificates
Expiring SSL certificates can cause a lot of problems in your Exchange environment, so it's a sensible idea to check them as part of your routine maintenance and health checks. I also use this script any time I am auditing a new environment for a troubleshooting case or a migration project.
Report on Mailbox Permissions
I frequently see people looking for scripts to help them gain some visibility of the mailbox permissions in their Exchange organization. Serkan Varoglu has published this PowerShell script that lets you produce a report of the mailbox permissions for a mailbox, a database, or the entire organization.
ActiveSync Device Statistics Report
As staff come and go in your organization the Exchange environment tends to accumulate stale mobile devices. This PowerShell script will generate a report of mobile devices that have not synced in a specified number of days. You can also use it to look at details such as which makes and models of mobile devices your users are connecting with. The report is generated in CSV and HTML email formats.
Recipient Address Report
Mike Crowley wrote this script to produce a report of every recipient's SMTP proxy addresses, which is very useful in a wide range of migration and management scenarios.
Update Calendar Folder Permissions
Exchange MVP Lasse Pettersson takes the guesswork out of whether you need to run Set-Mailboxfolderpermission, Add-Mailboxfolderpermissions, or Remove-Mailboxfolderpermission, by combining it all into one script that lets you add, update or remove permissions on mailbox folders.
Do you know of a useful PowerShell script that Exchange admins should know about? Feel free to add a comment below.
Note, please don't paste entire script contents into the comments below. Publish your script to TechNet, Github, or elsewhere if you want to share it with the community.