Last active
September 28, 2022 09:49
-
-
Save wgroenewold/f19bd551f27cfe95698e4229ed14018e to your computer and use it in GitHub Desktop.
Set all default permissions for all calendars in O365
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Connect-ExchangeOnline -UserPrincipalName [email protected] | |
$Mailboxes = Get-Mailbox -ResultSize Unlimited -Filter {(RecipientTypeDetails -eq "UserMailbox") -and (Name -ne "beheer")} | |
foreach($Mailbox in $Mailboxes){$Calendar = Get-Mailbox -Identity "$($Mailbox.Name)" | Get-MailboxFolderStatistics -FolderScope calendar | sort-object Date; Set-MailboxFolderPermission -identity "$($Mailbox.Name):\$($Calendar[0].Name)" -AccessRights LimitedDetails -User Default; foreach ($User in $Mailboxes){if($User -ne $Mailbox){Set-MailboxFolderPermission -identity "$($Mailbox.Name):\$($Calendar[0].Name)" -AccessRights Editor -User $($User.Name)}}} | |
foreach($Mailbox in $Mailboxes){$Calendar = Get-Mailbox -Identity "$($Mailbox.Name)" | Get-MailboxFolderStatistics -FolderScope calendar | sort-object Date; Set-MailboxFolderPermission -identity "$($Mailbox.Name):\$($Calendar[0].Name)" -AccessRights LimitedDetails -User Default; foreach ($User in $Mailboxes){if($User -ne $Mailbox){Add-MailboxFolderPermission -identity "$($Mailbox.Name):\$($Calendar[0].Name)" -AccessRights Editor -User $($User.Name)}}} |
Updated to mitigate unassigned object
Added some error handling, fallbacks and inline credentials
Oneliners ftw!
Now also available on decent OS:
Edited auth to new spec requirements, thanks @theemstra
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
will enable rooms in scheduling assistant in Outlook for Mac