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.
Steve’s blog | TechNet Script Gallery
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.
Michel’s blog | TechNet Script Gallery
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.
Zachary’s blog | TechNet Script Gallery
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.
Blog post | TechNet Script Gallery
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.
Blog post | TechNet Script Gallery
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.
Exchange Team blog | TechNet Script Gallery
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!
Blog post | TechNet Script Gallery
Compress and Archive IIS Logs
Keep your disk space utilization under control by regularly compressing and archiving the IIS logs on your Exchange Servers.
Blog post | TechNet Script Gallery
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.
Brian’s blog | Thomas’ blog | TechNet Script Gallery
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.
Blog post | TechNet Script Gallery
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.
Blog post | TechNet Script Gallery
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.
Mike’s blog | TechNet Script Gallery
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.
Blog post | TechNet Script Gallery
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.
Blog post | TechNet Script Gallery
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.
Mike’s blog | TechNet Script Gallery
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.
Lasse’s blog | TechNet Script Gallery
What’s Missing?
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.
https://blog.coingecko.com/trust-score-explained/#comment-10924
Binance clone
Binance Clone is an Asset trading platform developed by Codono integrated with multi coins and tokens wallet using Coin nodes or even 3rd party wallets Like CryptoApis, and Coinpayments. Also, Our Product enables the fastest Liquidity with multiple Liquidity Providers.
Hey Paul,
First of all I would like to thank you for Amazing scripts on various exchange tasks.
I am working on a requirement on Exchange 2013 and 2019 Infra coexistence environment wherein I need to collect logs from EWS IIS and SMTP Protocol logs.
Ask is:
Create a PowerShell function to collect logs depending on Date and Keywords inputs, Like I will take the input from user as:
-Date
-IP or -Username or -EmailAddress
-EWS or -IIS -or -SMTPProtocolLogs or -MessageTrackingLogs
Depending on the date input it should go inside the Logs directory (For IIS) and get the Logs and put them on a CSV file for review.
Where did the scripts to put servers in and out of Maintenance Mode go?
if can add script for Database leveling to be equal will be great
since some Application will create Mailboxes in only One Data base
Hey Paul,
Do you know if there is a way to clear out the MAPI sessions for a user using a script?
Thanks,
Nathan
Please help on a scrip that can be used to check each user mailbox and output if there is a rule that forwards externally, need it on Exchange 2016.
Hi Paul!
I am looking for a way to know through the script to which CAS the user / users is connected, I suppose that by reviewing the IIS records … We have a client disconnection problem and we must pull the thread …
Hi Paul,
some very nice scripts.
I’m searching a script which is telling me, how many contacts are inside a users mailbox.
We had a sync problem and as result some users have many duplicated contacts, 50000 instead of 1500.
Stefan
Pingback: guia exani ii
Pingback: Https://ferrann.com/blog/linaza-para-el-cabello/
Pingback: Https://www.mortaji.com/simulador-exani-ii/
Excellent Scripts
Thanks Paul & guys
KUDOS
Paul,
Another goodie that will make folks’ life easier – assign/remove O365 licenses in bulk:
http://ezoltan.blogspot.com/2017/12/assign-or-remove-o365-licenses.html
Zoltan
Hey Paul,
This can come handy – setting/resetting the maximum mailbox database size:
http://ezoltan.blogspot.com/2016/06/get-or-set-mailbox-database-maximum-size.html
Cheers,
Zoltan
Hi guys,
What about scripts to get top senders/recipients?
And getting an user list of connected users per protocol?
I think they are missing and are very requested.
Keep up the good work.
Cheers!
can you help me to get reports for CPU and RAM
Hey Paul, this is another nice one
https://blogs.technet.microsoft.com/exchange/2015/04/27/generating-user-message-profiles-for-use-with-the-exchange-calculators/
Hi Paul.
I’ve been searching, without success, for a script similar to the one that shows the mailbox permissions (Full Access, Send As and Send on behalf), but to show the Delegate/FolderPermissions.
I know the shell commands to get the permissions, but just with the results in Format-List/Table.
It’s been too many years since I touched development or even html.
Any chance you have a script for this that reports in HTML?
Thank you.
Excellent scripts…very useful stuff!!!
Excellent scripts…very useful stuff!!!
I’d like a script that would look at meeting rooms, identify all the organizers, then look in AD to see if the user was disabled or no longer with the company. Step 2 would be to be able to selectively delete them. That way you would not have phantom meetings clogging up your calendar.
That sounds like a useful script.
Thanks Paul for the scripts.
Hi Paul, Great stuff here! Regarding the Exchange Environment Script, is there a way to get OS Version and Service Pack information as well for the Edge Servers? I’m getting errors since these are located in DMZ. Thanks!
Hi, I love the script, works wonders. However, we don’t use Public Folders in our environment and was wondering if I could comment out or remove that from the script, which would help it run faster as well. Any suggestions? Thanks
I don’t know which script you’re referring to, but generally speaking yes you can edit the scripts to suit your requirements.
Hi Paul I am trying to use the Get-ExchangeEnviromentReport script as a schedule task, but it doesn’t seem to run. I can run the script from my exchange powershell, but just not as a task. Is there a way or can you tell me what to add to invoke the powershell.exe in the script? Please advise.
Paul I got this to work. I wish there was a nice way to show all the mailboxes like in exchange 2007. It had a colorful graphical report also in html that showed all users mailboxes and all the information related to it.
If you have feedback for Steve about his script by all means go and let him know at his blog, I’m sure he will appreciate it.
Good compilation; I seek knowledge around 2 areas I’ve not seen others script nor do you have on the list! 1.) How to create custom folders in Exchange 2013/2016 user mailboxes? 2.) How to Assign Custom Retention Policy Tags to the newly created custom folders?
The Below 2 links i’ve cobbled together to use EWS APIs and more complicated methods with lots of time… Anyone else covered this ground before? I can get folders created, but cannot get policies assigned. Sheesh, this was WAY easier in Exchange 07 Managed folders…
https://blogs.msdn.microsoft.com/emeamsgdev/2013/10/20/powershell-create-folders-in-users-mailboxes/
.Create-Folders.ps1 upn@suffix.local “E-Mail Retention” -ParentFolder “” -EwsManagedApiPath “c:Program FilesMicrosoftExchange ServerV15BinMicrosoft.Exchange.WebServices.dll”
.Create-Folders.ps1 upn@suffix.local “Keep for 4 years;Keep for 6 years;Keep for 10 years;Keep FOREVER” -ParentFolder “E-Mail Retention” -EwsManagedApiPath “c:Program FilesMicrosoftExchange ServerV15BinMicrosoft.Exchange.WebServices.dll”
https://blogs.msdn.microsoft.com/emeamsgdev/2016/04/22/powershell-apply-retention-policies-or-auto-archive-settings-to-inbox-sub-folders/
Any insight would be greatly appreciated and may help your Toolkit.
-Ron
Thank you Paul ! Really useful
Very useful. Thanks for your shared.
Instead of testing the mapi connectivity of all your mailbox servers one time, does anyone know how to measure the load of mapi connectivity on all your mailbox servers over a period (eg 24hrs)?
Thanks.
*a script
@Paul, thank you for your help.
I’m looking for an script to export a Exchange Online mailbox into PST using remote sessions in powershell, but as far as I know, there’s no nnew-mailboxexportrequest anymore… any help?
Thanks,
In EXO you can do a discovery search for all contents of a mailbox, and then download the search results as a PST.
Hi,
Thanks for sharing, I will add them to my collection
One not mentionned that I use all the time is the DAG database failover script notification.
This one was created by Nuno Mota and can be found here : https://social.technet.microsoft.com/Forums/en-US/5ed47ca6-55c9-4e01-8aa7-876486e5c89a/exchange-2010-failover-scipt-notification?forum=exchange2010
Thanks for the helpful share.
@Paul: great summary and we all really appreciate your engagement in sharing your tools with the rest of community for a long time.
As Thomas Oates pointed OOO, I got a script where you can list all users with currently active Autoreply. This might be an idea to rebuild it adding some more features and using your perfectionism in reports and add yet another script to your gallery.
Thank you for helping us .. really thank you
Excellent sharing. This blog give me a great help. I’m your fan now.
Another Exchange environment report is Exchange 2010 Architecture Report V2, it generate a HTML report that provides an overview of your Exchange environment.
https://gallery.technet.microsoft.com/scriptcenter/Exchange-2010-Architecture-9368ff56#content
Thank you Colin,
With Franck, we developed another Exchange 2010 Report, with more option.
https://gallery.technet.microsoft.com/office/Reporting-Exchange-2010-521cfdc0
and I must publish a report for Exchange 2013.
Regards.
Great list, funny thing is, I use most of these scripts on a daily basis. Took me a few years to find them all as needs arose though.
We have a useful Powershell script for setting out of office greetings. Very handy when someone leaves on vacation and forgets to set one. Medical leave, account terminations, etc. especially if you work in an environment where you need legal and/or HR to approve accessing a mailbox. Powershell allows you to set the OOO greeting without actually opening the mailbox with Outlook or OWA.
Sounds good. Care sharing? Thank you!
yeah sound real nice
Something similar to (users.txt with a list of users) :
import-csv users.txt | foreach {
$CustomMessage = “I am on Leave…. Whooohooooo”
$CustomMessage1 = “I am on Leave…. Whooohooooo”
Set-MailboxAutoReplyConfiguration $_.alias -AutoReplyState enabled -InternalMessage $CustomMessage -ExternalMessage $CustomMessage1
}
Great stuff ! ???
I would add
Admin Audit logs
http://mikepfeiffer.net/2010/08/administrator-audit-log-reports-in-html-format-exchange-2010-sp1/
Mailbox Audit logs
Generate HTML Report for Mailbox Audit Logs
https://gallery.technet.microsoft.com/office/Generate-HTML-Report-for-f30f66f3
Hi Paul… Amazing post as always… making admins life easier
You could add :
-MFCMAPI http://mfcmapi.codeplex.com/releases/view/104434
-Log parser Studio 2.0 http://gallery.technet.microsoft.com/Log-Parser-Studio-cd458765
awesome stuff
Thanks for putting it together into essential list
Hi Paul, excellent thanks again for this scripts
Paul Cunningham
do you have any scripts to list the users names from an AD group and then get their remote mailbox and apply limits to the mailbox of that user for number of email Limit the number of recipients when sending email