Skip to content

Instantly share code, notes, and snippets.

@AlexanderHolmeset
Created November 25, 2022 09:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexanderHolmeset/079627921af85ef316600ab86f067be0 to your computer and use it in GitHub Desktop.
Save AlexanderHolmeset/079627921af85ef316600ab86f067be0 to your computer and use it in GitHub Desktop.
$tenantsource = Connect-Site -Url "https://contoso-admin.sharepoint.com" -Browser
$tenantdest = Connect-Site -Url "https://tailspin-admin.sharepoint.com" -Browser
$UPNDomainSource = "contoso.onmicrosoft.com"
$UPNDomainDestination = "tailspin.onmicrosoft.com"
#List of users in the old tenant that are to be migrated. Header in CSV is UPN.
$users = import-csv 'C:\temp\UPN.csv'
$filepath = "C:\temp\CopyContentOneDrive.csv"
# Header for CSV file
"UPN,SourceSite,DestinationSite" >> $filepath
foreach($user in $users){
$userOneDriveURLSource = @()
$userOneDriveURLSource = Get-OneDriveUrl -Tenant $tenantsource -Email $user.UPN
$userUPN = @()
$userUPN = ($User.upn).replace("$UPNDomainSource","$UPNDomainDestination")
$userOneDriveURLDestination = @()
$userOneDriveURLDestination = Get-OneDriveUrl -Tenant $tenantdest -Email $userUPN -ProvisionIfRequired -DoNotWaitForProvisioning
"$($user.upn),$userOneDriveURLSource,$userOneDriveURLDestination" >> $filepath
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment