Forum Discussion
Migrate SharePoint sites libraries into one SharePoint site
Hi LeonPavesic ,
Thanks for your reply.
Can you please let me know the name/title of each column in this file File.csv?
Thanks
Hi Naligurtan,
The Excel file File.csv should have two columns:
- SiteUrl - The URL of the SharePoint site containing the document library.
- LibraryName - The name of the document library.
SiteUrl,LibraryName https://contoso.sharepoint.com/sites/Site1,Project Folder https://contoso.sharepoint.com/sites/Site2,Project Folder // ...
Please click Mark as Best Response & Like if my post helped you to solve your issue.
This will help others to find the correct solution easily. It also closes the item.
If the post was useful in other ways, please consider giving it Like.
Kindest regards,
Leon Pavesic (LinkedIn)
- NaligurtanOct 11, 2023Brass Contributor
Hi LeonPavesic
It does not work because I might have not explained in clearly and you may not have understood me.I will try explain it here again. I am also attaching a screenshot.
There are over 1000 sites on the prem with ONLY one document library (Project%20Folder). I created ONLY one site on SharePoint online. I want to move all sites’ document libraries (Project%20Folder) into the new SharePoint site as a document library with the same name of the prem sites (GP56077, GP56121).
All Site names from the old sites/on prem became a document library name in the new SharePoint site. All files from the Project%20Folder document libraries needs to be moved into the new document libraries such as GP56077, GP56121 etc.Please see the screenshot below.
- LeonPavesicOct 12, 2023Silver Contributor
Hi Naligurtan,
thanks for the update, I understand your issue better now.Here is a PowerShell script that you can use to migrate all of the document libraries from your SharePoint on-premises farm to a single document library in SharePoint Online, with the same name as the original document libraries (you can use it perhaps as a starting point)
# Import the SharePoint PnP PowerShell module Install-Module SharePointPnPPowerShellOnline # Connect to your SharePoint on-premises farm Connect-PnPOnline -Url https://your-onprem-sharepoint-farm-url # Create a variable to store the list of SharePoint on-premises sites $onpremSites = Get-PnPSite # Create a variable to store the target document library URL in SharePoint Online $targetLibraryUrl = "https://your-tenant-domain.sharepoint.com/sites/Projects/Library/" # Iterate through the list of SharePoint on-premises sites foreach ($onpremSite in $onpremSites) { # Get the document library name in the SharePoint on-premises site $sourceLibraryName = "Project%20Folder" # Create the target document library in SharePoint Online if it does not exist if (-Not (Test-PnPList -ListUrl $targetLibraryUrl/$sourceLibraryName)) { New-PnPList -ListName $sourceLibraryName -TemplateId "100" -ParentSiteUrl $targetLibraryUrl } # Get the document library URL in the SharePoint on-premises site $sourceLibraryUrl = $onpremSite.Url + "/" + $sourceLibraryName # Copy the files from the SharePoint on-premises document library to the target document library in SharePoint Online Copy-PnPFile -SourceUrl $sourceLibraryUrl -TargetUrl $targetLibraryUrl/$sourceLibraryName }
This script should first check if the target document library exists in SharePoint Online. If it does not exist, the script should create it.
Then, the script should copy all of the files from the SharePoint on-premises document library to the target document library in SharePoint Online.Please click Mark as Best Response & Like if my post helped you to solve your issue.
This will help others to find the correct solution easily. It also closes the item.If the post was useful in other ways, please consider giving it Like.
Kindest regards,
Leon Pavesic
(LinkedIn)- NaligurtanOct 12, 2023Brass ContributorThanks. I am testing it and let you know the result. Thanks again.