Public/Configuration/Add-DefaultCalenderPolicy.ps1
function Add-DefaultCalendarPolicy { param( [Parameter(Mandatory)] [string]$TenantId ) try { Write-ModuleLog -Message "Adding default calendar policy for tenant $TenantId" -Level Info -Component 'Add-DefaultCalendarPolicy' Connect-CustomerExchange -CustomerTenantId $TenantId Get-Mailbox | Where-Object Name -NotLike 'Discovery*' | ForEach-Object { $mail = $_.UserPrincipalName Write-ModuleLog -Message "Creating default policy for $mail" -Level Info -Component 'Add-DefaultCalendarPolicy' $calendarName =(Get-EXOMailboxFolderStatistics -Identity $mail -Folderscope Calendar | Where-Object FolderType -eq 'Calendar').Name Set-MailboxFolderPermission $mail":\"$calendarName -User Default -AccessRights Reviewer } } catch { throw $_ } } |