M365 Migration - helpful scripts
-
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
-
My real time saver
This will import a list of users, and grant them PublishingEditor to all members of the desired group.
$Group = 'NPP' $ImportCsvFile = 'c:\esd\tuc-users-clean1.csv' $employee_list = Import-Csv $ImportCsvFile ForEach ($employee in $employee_list) { ForEach ($User_Mailbox in (get-azureadgroup -Filter "Displayname eq '$Group'" | get-azureadgroupmember -All $true)) { add-mailboxfolderpermission -Identity "$($User_Mailbox.displayname):\Calendar" -User $employee.UserPrincipalName -AccessRights PublishingEditor $User_Mailbox.Displayname $employee.UserPrincipalName } }
-
@dashrender You used
$group
but did not define it in your first example. -
@jaredbusch said in M365 Migration - helpful scripts:
@dashrender You used
$group
but did not define it in your first example.it's not defined on purpose - several of these have undefined, it's expected that you will define/replace them yourself.
-
@dashrender said in M365 Migration - helpful scripts:
@jaredbusch said in M365 Migration - helpful scripts:
@dashrender You used
$group
but did not define it in your first example.it's not defined on purpose - several of these have undefined, it's expected that you will define/replace them yourself.
That is a very poor guide. You posted a script. I expect to copy and paste it and see something work.
-
@jaredbusch said in M365 Migration - helpful scripts:
@dashrender said in M365 Migration - helpful scripts:
@jaredbusch said in M365 Migration - helpful scripts:
@dashrender You used
$group
but did not define it in your first example.it's not defined on purpose - several of these have undefined, it's expected that you will define/replace them yourself.
That is a very poor guide. You posted a script. I expect to copy and paste it and see something work.
How could I possibly know the names of your groups?
-
@jaredbusch said in M365 Migration - helpful scripts:
@dashrender said in M365 Migration - helpful scripts:
@jaredbusch said in M365 Migration - helpful scripts:
@dashrender You used
$group
but did not define it in your first example.it's not defined on purpose - several of these have undefined, it's expected that you will define/replace them yourself.
That is a very poor guide. You posted a script. I expect to copy and paste it and see something work.
Jared is right to a point.
I've now gone back and added variables to all of my scripts making it easier for someone using these to see that they need to enter their own information into the variables to make it work.
I could take it a step further and prompt for that data - but one thing at a time. -
@dashrender said in M365 Migration - helpful scripts:
@jaredbusch said in M365 Migration - helpful scripts:
@dashrender said in M365 Migration - helpful scripts:
@jaredbusch said in M365 Migration - helpful scripts:
@dashrender You used
$group
but did not define it in your first example.it's not defined on purpose - several of these have undefined, it's expected that you will define/replace them yourself.
That is a very poor guide. You posted a script. I expect to copy and paste it and see something work.
Jared is right to a point.
I've now gone back and added variables to all of my scripts making it easier for someone using these to see that they need to enter their own information into the variables to make it work.
I could take it a step further and prompt for that data - but one thing at a time.