Skip to content

Instantly share code, notes, and snippets.

@AlexanderHolmeset
Created November 25, 2022 09:54
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/b513f895ba54da093e6a34fb6b16ff00 to your computer and use it in GitHub Desktop.
Save AlexanderHolmeset/b513f895ba54da093e6a34fb6b16ff00 to your computer and use it in GitHub Desktop.
Import-Module Sharegate
$csvFile = "C:\temp\CopyContentOneDrive.csv"
$table = Import-Csv $csvFile -Delimiter ","
$tenantsource = Connect-Site -Url "https://contoso-admin.sharepoint.com" -Browser
$tenantdest = Connect-Site -Url "https://tailspin-admin.sharepoint.com" -Browser
$copysettings = New-CopySettings -OnContentItemExists IncrementalUpdate
Set-Variable srcSite, dstSite, srcList, dstList
foreach ($row in $table) {
Clear-Variable srcSite
Clear-Variable dstSite
Clear-Variable srcList
Clear-Variable dstList
$srcSite = Connect-Site -Url $row.SourceSite -UseCredentialsFrom $tenantsource
$dstSite = Connect-Site -Url $row.DestinationSite -UseCredentialsFrom $tenantdest
#The name of the folder is dependant on what language you use in your tenant.
#Run Get-List -Site $srcSite to see what the name of the documents foldr is
$srcList = Get-List -Site $srcSite -Name "Documents"
$dstList = Get-List -Site $dstSite -Name "Documents"
Copy-Content -SourceList $srcList -DestinationList $dstList -CopySettings $copysettings
#comment out bellow commands if you plan on running a incremental copy later.
Remove-SiteCollectionAdministrator -Site $srcSite
Remove-SiteCollectionAdministrator -Site $dstSite
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment