Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
$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