2

I want to move documents from SharePoint 2013 on-prem mysite to one drive using PowerShell. Are there scripts available to do so? Can someone help?

Basically I'm creating a folder in one drive and want to move the documents from on-prem to these folders using PowerShell

  • Do need to migrate documents one-time or is this something you need to run periodically on a schedule? – Lars Fastrup Mar 23 '17 at 12:06
  • @LarsFastrup: It is one time but we have 400 libraries to be moved to 200 one drive sites – George Mar 23 '17 at 12:16
1

The SharePoint Online Management Shell includes migration cmdlets. It is designed to handle lists from on-prem or generate packages from file shares. Export the content from your on-prem farm and then target and import to your destination. Outside of documents and lists, you will need to use other tools to migrate other customizations (e.g. web parts, theming, etc.).

(Disclosure: I worked on the Microsoft PowerShell migration tool)

# Run from the SharePoint Online Management Shell 
$creds = (Get-Credential admin@contoso.com)

$sourceWeb = 'http:\\sharepoint\sites\sourceSite'
$sourceList = '\documents'

$sourceFiles = '\\server\share\sam\package'
$sourcePackage = '\\server\share\sam\package'

$targetPackage = '\\server\share\sam\packageTarget'
$targetWeb = 'https://contoso-my.sharepoint.com/personal/sam_contoso_com'
$targetDocLib = 'Documents'

# Export package from SharePoint
Export-SPWeb -Identity $sourceWeb -Path $sourcePackage -NoFileCompression -ItemUrl $sourceList -IncludeVersions All -IncludeUserSecurity

# Convert package to a targeted one by looking up data in target site collection
$convertedPackage = ConvertTo-SPOMigrationTargetedPackage -SourceFilesPath $sourceFiles `
    -SourcePackagePath $sourcePackage `
    -OutputPackagePath $targetPackage `
    -TargetWebUrl $targetWeb `
    -TargetDocumentLibraryPath $targetDocLib `
    -Credentials $creds

# Encrypt, upload to Azure, and submit the migration
$report  = Invoke-SPOMigrationEncryptUploadSubmit -MigrationSourceLocations $convertedPackage `
    -TargetWebUrl $targetWeb `
    -Credentials $creds

# Get the progress of the migration job
Get-SPOMigrationJobProgress -AzureQueueUri $report.ReportingQueueUri `
    -TargetWebUrl $targetWebUrl `
    -JobIds $report.jobId `
    -EncryptionParameters $report.Encryption `
    -Credentials $creds
  • @zachkoehe Many thanks for the script.. How do we create $sourceFiles, $sourcePackage,$targetPackage? – George Mar 27 '17 at 8:42
  • $sourceFiles and $sourcePackage are the same. They point to the file path where you exported data from SharePoint using the Export-SPWeb command. $targetPackage is an empty directory. This will contain the metadata used for the migration to the target site in SharePoint Online. – Zach Mar 27 '17 at 15:35
  • Hi Zach, above approach worked for normal list, but it does not work for Lookup list.facing this issue "Errors or timeout for Server Processing the file:Fail to lookup folder name. The item may exist in other list or site in the same site collection" – Amay Kulkarni Jun 26 '18 at 14:07
0

You should look into getting an off the shelf product. This is definitely possible to do in PowerShell but that is a significant amount of work that doesn't really get given away for free.

If you write a script and struggle with a particular problem I am sure many people here would be more than willing to help you.

0

You could always open each path in Windows Explorer and copy/paste from there (if you don't care about preserving metadata, version history, etc.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.