Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
$tenantsource = Connect-Site -Url "" -Browser
$tenantdest = Connect-Site -Url "" -Browser
$UPNDomainSource = ""
$UPNDomainDestination = ""
#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