PowerShell – script to show all mailbox rules and disable selected ones

Ever needed to quickly find and disable mail rules in user mailboxes? Look no further as the script below does all of it. It’s a convenience by itself to not go into Exchange Admin Portal, but there might be cases where your user gets hacked, some bad person creates a rule or two. Then you need to disable those quickly. So this script does the following to a specified email: lists all mailbox rules and shows their most important info - its actions, description, and status; then you can select and disable any rule by typing its number until (if desired) all rules are disabled. Don’t forget to replace @contoso.com with your own domain. #---------------------------------------[Functions]--------------------------------------------------- Function List-Rules { param ( [Parameter(Mandatory=$True)]$email ) Begin{} Process{ $collection = @() $i = 0 $rules = Get-InboxRule -Mailbox $email ForEach ($rule in $rules) { $outObject = "" | Select Number,Status,"Rule Name","Applies to emails From","Delete…

Continue Reading

PowerShell – auxiliary script to populate CustomAttribute10 with a Purged Items FolderID

Originally this script ( New-ComplianceSearch script ) would search through Purged Items. That was the downside of it comparing to a "classic" Search-Mailbox you can find here ( Search-Mailbox script ). So imagine you run the script the 1st time, find target messages, and then delete them - the found results make sense. However, should you run the script the 2nd time with the same search criteria, it would find those already purged messages again. That creates some confusion. So it would be great to exclude Purged Items folders from the search. Now, it is possible to do so on the fly ( https://docs.microsoft.com/en-us/microsoft-365/compliance/use-content-search-for-targeted-collections ) but it is very time consuming and takes about 1-3 seconds for each mailbox which stacks up pretty fast. So I came up with a script to take care of this issue by storing a Purged Items FolderID in a CustomAttribute10 of each mailbox. So…

Continue Reading

Script to search through Recoverable and Purged items and restore those

The purpose of this script is to find deleted messages in a specified user's mailbox. There are 3 levels (when configured) of Trash in a mailbox: Level 1 - Deleted Items (e.g. 30 days) Level 2 - Recoverable items (e.g. 15 days) Level 3 - Purged items (e.g. 15 days) Users usually know about the first two. Moreover, they can only work with the first two from both Outlook and OWA. Only admins have access to Purged items. It makes sense to use this script in at least 2 cases: A user is being terminated on bad terms, decided to permanently delete everything from both Deleted and Recoverable items. A user deleted an email at some point, missed the first 30-day period, then missed the second 15-day period, and then wants to recover that email. If it's less than 60 days (30+15+15) overall then that email can be restored. The script…

Continue Reading

Script to get mailbox size and number of items info for all users or a single one

This script has two parts in it and depending on the selection it will either run it against a single specified mailbox or all of them at once. Note, running this script against a few hundred mailboxes takes several minutes. So if your company is large with thousands of mailboxes, expect it to take much longer. As part of the output it lists the following parameters - a user name, number of items in the mailbox, its current size, and a maximum allowed size. There is a downside of using this script when running it against all mailboxes. Because Get-MailboxStatistics outputs TotalItemSize as a string only, it makes it harder to search through and sort by. I wish Microsoft could change that and provide data in a number type format. $answer = Read-Host "Would you like to get statistics for all users ( y / n )?" While ("y","n" -notcontains $answer)…

Continue Reading

Script to turn a Shared Mailbox into an automated calendar only or a combination of both

The purpose of this PowerShell script is to adjust an existing Shared Mailbox to auto-accept calendar invitations and either keep emails or automatically remove them. Why would you do that as an admin? Well, there are 2 scenarios for it, and the choice really depends on the department / team in your company and their needs: 1) Its only purpose is a Calendar (e.g. team calendar for vacations) 2) Its purpose is a combination of a Calendar and a Mailbox (e.g. Help Desk mailbox and team calendar for vacations combined rather than two entities separately). Regardless, the way it works for users - they invite that calendar as a participant when creating vacation bookings. Thus, those bookings will be visible in both a personal calendar and a team calendar. What this script does: Turns on auto-processing; Allows conflict creation; Either deletes emails or keeps them depending on a scenario from…

Continue Reading

Add corporate or custom holidays to user calendars – 2nd method – bulk

Most companies, if not all, have their own set of holidays on top of national ones. So, distributing them is a pretty common task for an Office 365 / Exchange admin. There are different approaches out there with their own pros and cons. I’ve come up with two methods that combined give me a great result. In this post let’s focus on the 2nd method – a bulk one. I came up with this method after doing the migration from IBM Domino to Office 365. It looks complicated but after doing it several times you'll get comfortable and it won't be taking much time anymore. To see more about the 1st method (manual), please follow this link - Add corporate or custom holidays to user calendars – 1st method – manual PREREQUISITES: 1) Download and install (please use default settings) Azure Storage Explorer 2) Prepare a .csv file with all accounts using the…

Continue Reading

Add corporate or custom holidays to user calendars – 1st method – manual

Most companies, if not all, have their own set of holidays on top of national ones. So, distributing them is a pretty common task for an Office 365 / Exchange admin. There are different approaches out there with their own pros and cons. I’ve come up with two methods that combined give me a great result. In this post let’s focus on the 1st method - a manual one. To see more about the 2nd method (bulk), please follow this link – Add corporate or custom holidays to user calendars – 2nd method – bulk So, all you have to do is create a text file, change its extension to *.hol, name it with something that makes sense (e.g. 2019 Contoso Holidays.hol), put a text content similar to my example below: [Contoso Holidays] 3 New Year, 2019/01/01 Contoso Birthday, 2019/04/28 Planned Shutdown, 2019/12/31 where [Contoso Holidays] is a location and "3"…

Continue Reading

List all mail folders for a specified user to easily locate a missing folder

If you have ever seen these user requests, then this simple PowerShell script is for you: I've dragged my mail folder and now I cannot find it anymore; I've clicked on something, and now the folder is gone; I haven't done anything, but that folder was here yesterday. These types of requests are not an issue if you are dealing with a user who has several folders in addition to the standard ones. However, it's not that uncommon for a user to have a hundred of them or even more. This is when manually searching for a lost folder turns into something big. What this PowerShell script does, it shows all mailbox folders for a specified user and the path each one of those folders has. The result is shown in a Grid View that allows you to sort and search/filter. So simply search for a name your user told…

Continue Reading
Close Menu