Add migration scripts
This commit is contained in:
		
							parent
							
								
									6db794ce28
								
							
						
					
					
						commit
						0601036fd5
					
				
							
								
								
									
										22
									
								
								m365/migration/Grant-SPOPersonalSiteCollectionAdmin.ps1
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								m365/migration/Grant-SPOPersonalSiteCollectionAdmin.ps1
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,22 @@
 | 
				
			|||||||
 | 
					#Requires -Modules Microsoft.Online.SharePoint.PowerShell
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Set the SharePoint Admin page URL
 | 
				
			||||||
 | 
					$AdminUrl = 'https://contoso-admin.sharepoint.com'
 | 
				
			||||||
 | 
					# Set the migration account name
 | 
				
			||||||
 | 
					$MigrationAccount = 'migration@contoso.com'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Check and connect to the SPOService if we're not already
 | 
				
			||||||
 | 
					$SiteCheck = ''
 | 
				
			||||||
 | 
					Try {
 | 
				
			||||||
 | 
					    $SiteCheck = Get-SPOSite $AdminUrl
 | 
				
			||||||
 | 
					} Catch [System.InvalidOperationException] {
 | 
				
			||||||
 | 
					    Connect-SPOService -Url $AdminUrl
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Get SPO personal sites
 | 
				
			||||||
 | 
					$PersonalSites = Get-SPOSite -IncludePersonalSite $true | Where-Object { $_.Url -like "*personal*" }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					foreach ($Site in $PersonalSites) {
 | 
				
			||||||
 | 
					    # Grant $MigrationAccount Site Collection Admin on each personal site
 | 
				
			||||||
 | 
					    Set-SPOUser -Site $Site.Url -LoginName $MigrationAccount -IsSiteCollectionAdmin $true
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										68
									
								
								m365/migration/README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										68
									
								
								m365/migration/README.md
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,68 @@
 | 
				
			|||||||
 | 
					# Exchange Online PowerShell Migration Tools
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					This is a collection of useful commands and scripts to aid in Exchange Online tenant migrations.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Before running these commands, [install and import the Exchange Online PowerShell module](https://learn.microsoft.com/en-us/powershell/exchange/connect-to-exchange-online-powershell?view=exchange-ps) and connect:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```powershell
 | 
				
			||||||
 | 
					Install-Module ExchangeOnlineManagement
 | 
				
			||||||
 | 
					Import-Module ExchangeOnlineManagement
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Connect-ExchangeOnline
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## Get email aliases
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Use this command to get a list of aliases for all mailboxes. Optionally specify a mailbox: `Get-Mailbox 'bsmith@contoso.com' | ...`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```powershell
 | 
				
			||||||
 | 
					Get-Mailbox | select DisplayName,PrimarySmtpAddress,@{n='EmailAliases';e={$_.EmailAddresses -cnotmatch 'SMTP:|SPO:|SIP:|[xX]500:' -replace 'smtp:','' -join ',' }}
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					DisplayName                        PrimarySmtpAddress                                  EmailAliases
 | 
				
			||||||
 | 
					-----------                        ------------------                                  ------------
 | 
				
			||||||
 | 
					Barbie Smith                       bsmith@contoso.com                                  barbie@contoso.onmicrosoft.com
 | 
				
			||||||
 | 
					Clement Jones                      cjones@contoso.com                                  clement@contoso.onmicrosoft.com
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					If you'd like to export this to CSV, replace the `-join` parameter with a semicolon, and pipe to `Export-Csv` like so:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```powershell
 | 
				
			||||||
 | 
					Get-Mailbox | select DisplayName,PrimarySmtpAddress,@{n='EmailAliases';e={$_.EmailAddresses -cnotmatch 'SMTP:|SPO:|SIP:|[xX]500:' -replace 'smtp:','' -join ';' }} | Export-Csv -Path 'C:\Path\To\Export.csv' -NoTypeInformation
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## Get group membership
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Get a list of distribution and Microsoft 365 Teams and their members.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```powershell
 | 
				
			||||||
 | 
					Get-Group | where { $_.RecipientType -ne "Group" } | select DisplayName,@{n='Members';e={ $_.Members -join ',' }
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Follow the same process as above to export to CSV.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## Grant-SPOPersonalSiteCollectionAdmin
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Use this script to grant an admin or migration account the CollectionAdmin role to all personal SharePoint Online sites (OneDrive). This is required if using a single migration account to copy OneDrive data to a new tenant.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Before running this script, [install and import the SharePoint Online PowerShell module](https://learn.microsoft.com/en-us/powershell/sharepoint/sharepoint-online/connect-sharepoint-online):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```powershell
 | 
				
			||||||
 | 
					Install-Module Microsoft.Online.SharePoint.PowerShell
 | 
				
			||||||
 | 
					Import-Module Microsoft.Online.SharePoint.PowerShell
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					The script will connect to the SPO Admin center with the configured admin center URL:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```powershell
 | 
				
			||||||
 | 
					# Set the SharePoint Admin page URL
 | 
				
			||||||
 | 
					$AdminUrl = 'https://contoso-admin.sharepoint.com'
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					You will also need to set the UPN of the migration account:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```powershell
 | 
				
			||||||
 | 
					# Set the migration account name
 | 
				
			||||||
 | 
					$MigrationAccount = 'migration@contoso.com'
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user