The script saves calendar processing settings of a Microsoft 365 (Office 365) mailbox to a multi-valued Active Directory attribute. To run the script, create a scheduled task configured for the User object type.
Parameters:
- $attributeName - Specifies the LDAP name of the multi-valued attribute to hold calendar processing settings.
- $settingsMap - Maps names of the settings as returned by PowerShell and their respective display names as they should be displayed in Adaxes. Settings not included in this map will be ignored and will not be added to the AD attribute.
PowerShell
$attributeName = "adm-CustomAttributeTextMultiValue1" # TODO: modify me
$settingsMap = @{
"AutomateProcessing" = "Automate Processing Enabled";
"AllowConflicts" = "Allow Conflicts";
"BookingWindowInDays" = "Booking Window in Days";
"AllowRecurringMeetings" = "Allow Recurring Meetings";
"ScheduleOnlyDuringWorkHours" = "Schedule Meetings Only During Work-Hours";
"OrganizerInfo" = "Organizer Info";
"ResourceDelegates" = "Resource Delegates";
"RemoveOldMeetingMessages" = "Remove Old Meeting Messages";
"ProcessExternalMeetingMessages" = "ProcessExternalMeetingMessages";
"RemoveForwardedMeetingNotifications" = "Remove Forwarded Meeting Notifications";
} # TODO: modify me. Example $settingsMap = @{ "<PropertyName>" = "<Property Display Name>"; }
# Get the object ID in Microsoft 365
try
{
$objectId = [Guid]$Context.TargetObject.Get("adm-O365ObjectId")
}
catch
{
$Context.LogMessage("The user doesn't have a Microsoft 365 account", "Warning")
return
}
try
{
# Connect to Exchange Online
$session = $Context.CloudServices.CreateExchangeOnlinePSSession()
Import-PSSession $session -AllowClobber -DisableNameChecking -CommandName "Get-CalendarProcessing"
# Get calendar processing options
$processingOptions = Get-CalendarProcessing -Identity $objectId.ToString()
$values = @()
foreach ($propertyName in $settingsMap.Keys)
{
$values += "$propertyName`: " + ($processingOptions.$propertyName -join ",")
}
# Save information to AD account
$Context.TargetObject.Put($attributeName, $values)
$Context.TargetObject.SetInfo()
}
finally
{
# Close the remote session and release resources
if ($session) { Remove-PSSession $session }
}