If you have ever worked with Calendar Processing you may have encountered times when invalid LegacyExchangeDN's are present in the Calendar Processing options, which prevents you from updating the resource mailbox when executing the Set-CalendarProcessing cmdlet, or updating a resource mailbox's delegation from Outlook or OWA. OWA particularly may throw an "unknown error".

What this script does is gathers all the LegacyExchangeDN's from the CalendarProcessing BookInPolicy, RequestInPolicy, RequestOutOfPolicy and ResourceDelegates, and validate each entry to see which are invalid, or stale objects.

These stale objects can remain within the CalendarProcessing when a User object is removed from Active Directory without removing the mailbox, or the Mailbox exceeds the databases MailboxRetention setting and is removed from the database. When this happens the Mailbox's LegacyExchangeDN is not removed from the various Resource Mailboxes Calendar Processing in the organization. This is because the Remove-ADUser cmdlet has no backlink into Exchange to perform such tasks.

To use this script, download and import the module.

Import-Module CalendarProcessingTools.psd1

You can then run the Search-RoomPolicies cmdlet, use Get-Help Search-RoomPolicies -examples to see how to use the script.

This script can also generate a report of all the invalid LegacyExchangeDN's in resource mailboxes.

Permissions required:

You will need to ensure you can execute the Set-CalendarProcessing cmdlet in order to make full use this module if you intend to fix these inconsistencies.

Supported Versions of Exchange:

Feel free to comment and post feedback on the script or if you would like to have additional functionality added.

PowerShell
Edit|Remove
Function Search-RoomPolicies { 
 
# .SYNOPSIS 
#   Check MeetingRooms BookInPolicy, RequestInPolicy, RequestOutOfPolicy and ResourceDelegates for invalid mailboxes. 
# 
# .DESCRIPTION 
#    This script will check a resource mailboxes' CalendarProcessing for LegacyExchangeDN of invalid objects that have been removed from Active Directory or tombstoned. 
# 
# .PARAMETER MeetingRoom 
#    Specify the RoomMailbox. This parameter accepts Alias, CanonicalDN, Display Name, Distinguished Name, Domain\Account, GUID, Immutable ID, LegacyExchangeDN, SMTP Address, or UPN. 
# 
# .PARAMETER All 
#    Selects all RoomMailbox's in the organization. 
# 
# .PARAMETER GenerateReport 
#    Use this switch to generate a report of all invalid object LegacyExchangeDN's for each room. 
# 
# .PARAMETER Path 
#    Use this switch to specify a path to export the report, to be used in conjunction with the -GenerateReport parameter otherwise the default path will be used. 
# 
# .EXAMPLE 
#    Search-RoomRequestInPolicy -MeetingRoom boardroom@contoso.com 
#   This will check only a single meeting room for invalid objects in the RequestInPolicy. 
# 
# .EXAMPLE 
#    Search-RoomRequestInPolicy -MeetingRoom boardroom@contoso.com -GenerateReport 
#   This will check only a single meeting room for invalid objects in the RequestInPolicy and generate a report to C:\Temp\InvalidEntries.csv. 
# 
# .EXAMPLE 
#    Search-RoomRequestInPolicy -MeetingRoom boardroom@contoso.com,conferenceroom@contoso.com 
#   This will check multiple meeting rooms for invalid objects in the RequestInPolicy. 
# 
# .EXAMPLE 
#    Search-RoomRequestInPolicy -MeetingRoom boardroom@contoso.com,conferenceroom@contoso.com -GenerateReport 
#   This will check multiple meeting rooms for invalid objects in the RequestInPolicy and generate a report to C:\Temp\InvalidEntries.csv. 
# 
# .EXAMPLE 
#    Search-RoomRequestInPolicy -All -GenerateReport -Path C:\Reports\AllInvalidObjects.csv 
#   This will check all meeting rooms for invalid objects in the RequestInPolicy and generate a report to the custom path C:\Reports\AllInvalidObjects.csv. 
# 
# .NOTES 
# Copyright (c) 2017 Microsoft Corporation. All rights reserved. 
# 
# THIS CODE IS MADE AVAILABLE AS IS, WITHOUT WARRANTY OF ANY KIND. THE ENTIRE RISK 
# OF THE USE OR THE RESULTS FROM THE USE OF THIS CODE REMAINS WITH THE USER.