I'm migrating from on-premise Exchange to M365. I'm doing a cutover process.
One of issues I've run into is M365 doesn't work well with group permissions to get users to access other people's calendars. As such I need to remove all the new useless groups from my select users, then script in access for all the users.
These scripts require you to made modifications for your own use.
First script here is listing all the permissions on a list of mailboxes in a give group.
$Group = 'name of your group here'
ForEach ($User_Mailbox in (get-azureadgroup -Filter "Displayname eq '$Group'" | get-azureadgroupmember -All $true))
{
Get-MailboxFolderPermission -Identity "$($User_Mailbox.Displayname):\Calendar"
}
Next is deleting a specific user/group from the calendar permission
$Group = 'your group name here'
ForEach ($User_Mailbox in (get-azureadgroup -Filter "Displayname eq '$Group'" | get-azureadgroupmember -All $true))
{
Remove-MailboxFolderPermission -Identity "$($User_Mailbox.Displayname):\Calendar" -User "name of user/group to remove"
}
With the remove command, you can add -Confirm:$false to have it skip confirming each removal.
Export a full list of users from Azure AD
$FilePath = 'the path where you want your CSV file saved'
get-azureaduser -All $true | Select-Object -Property UserPrincipalName,Displayname | Export-Csv -Path $FilePath