In the days of conference rooms are all booked most of the days, some of the meetings are recurring meetings, we all struggle to find a conference room to our next meeting. Here is the catch. There is a (recurring) meeting hogging the conference room, but the meeting organizer left the company.
I dealt with this issue and found a couple of solutions on how to clean up the conference room calendar.
Note: both ideas do not require you to take full control of the mailbox and read emails/meeting items unintentionally. You do need an Admin privilege in Exchange Online and Compliance permissions. I will let you figure out the permissions.
1. Cancel all future meetings from the user’s mailbox
This is the cleaner solution. This solution will cancel all future meetings from User’s mailbox and send out meeting cancellation notices to all attendees. Since we are talking about user who no longer works in the company, her/her account is mostly in disabled state. So, the solution to restore the mailbox back into Exchange Online. That means you have to do this within the 30 days (deleted mailbox purge schedule).
Enable the user account and assign the Microsoft/Office 365 license. Give it time to Office 365 to restore the mailbox. Then run this command after connecting to Exchange Online (Connect-ExchangeOnline) in PowerShell.
Remove-CalendarEvents -Identity John.Doe@company.com -CancelOrganizedMeetings -QueryWindowInDays 180
QueryWindowInDays are mandatory property for “Remove-CalendarEvents” command. It says how far along we want to cancel the meeting from the calendar.
I would run the command as part of the employee termination process before you disable the account.
Source: https://learn.microsoft.com/en-us/powershell/module/exchange/remove-calendarevents?view=exchange-ps
2. Delete the meetings from Conference rooms
I chose this method for the user who booked the meetings and left the company more than 30 days ago and we cannot restore his mailbox.
P.S. You need Exchange Administrator permission and compliance administrator permission to preview and purge the items.
Here is an overview of the solution: you will do a compliance search on the conference room(s) of the meeting booked by the user who no longer works. Then use the search object to purge (delete) the meetings from the conference rooms. This will not send out meeting cancellation notices, but the meeting will get deleted from the conference room & frees up the schedule so others can book.
- Connect to Exchange Online and Compliance center in PowerShell
Connect-ExchangeOnline
Connect-IPPSSession -EnableSearchOnlySession
2. Run a Compliance Search command to search meetings booked by the user (who no longer works).
Note: ContentMatchQuery parameter searches only meetings with (kind=meeting) option. To specify the meeting organizer, use (senderauthor=emailaddress-of-the-user) in the query. ExchangeLocation option to specify to mailboxes to search in our case conference room mailbox email addresses separated by the comma.
New-ComplianceSearch -Name "Meeting-booked-by-John-Doe" -Description "Any notes you want" -ContentMatchQuery "(c:c)(kind=meetings)(senderauthor:John Doe)" -ExchangeLocation conference-room-1,conference-room-2 -Force
3. Start the Compliance search. Note the search name we provided in above command “Meeting-booked-by-John-Doe”.
Start-ComplianceSearch -Identity "Meeting-booked-by-John-Doe"
4. Run Get-ComplianceSearch –Identity “Meeting-booked-by-John-Doe” | fl to check “Items” property to see how many items the search found. Hopefully you see more than 0 items.
Now Do you want to see the search results? If not, skip step 5.
5. The search results can be viewed in PowerShell. But it will be in raw format. I wrote this function to parse the search results. Copy/paste this function to the PowerShell to load this function to the memory. The parameter to this function can be pipe-lined from Get-ComplianceSearchAction command. Note the option (ValueFromPipeline=$true).
function PreparePreviewResults
{
Param (
[Parameter(ValueFromPipeline=$true)]
$SearchResults
)
$SearchResults = $SearchResults.Results.Replace('{','').Replace('}','')
$data = "Location,Sender,Subject,Type,Size,Received Time,Data Link`n"
$SearchResults | ForEach-Object { $t=""; $_.Split(';').foreach({ $t += $_.Split(":")[1].Trim() +",); $data += $t + "`n" }
Return ($data | ConvertFrom-Csv)
}
Create a new compliance search action with preview option by running the following command. We are saving the search action object to the variable $SearchAction. This variable will be used in the next commands.
$SearchAction = New-ComplianceSearchAction -SearchName "Meeting-booked-by-John-Doe" -Preview
The following command piped the “Results” property to the above function to parse the results. You may use Export-CSV command in the end instead of Out-GridView.
Out-GridView will show the results in table format in the screen. Export-Csv will export the results to the CSV file.
Get-ComplianceSearchAction -Identity $SearchAction.Name | Select-Object Results | ForEach-Object {$_.Results } | PreparePreviewResults | Out-GridView
If you are happy to see the correct results, go to the next step to delete the meeting items.
6. Create new compliance search action to purge the search results from the conference room(s).
New-ComplianceSearchAction -SearchName "Meeting-booked-by-John-Doe" -Purge -PurgeType HardDelete -Force
That’s it. You deleted the meeting booked by the ex-employee on the conference room(s). I hope it helped you.