Bringing your TB size documents with a set of metadata to your O365 environment is challenging. 

Environment Setup for remote machine

In order to enable SharePoint Online PowerShell Script execution from your remote machine. Click here for setup steps



Source Code


Figure depicted as below

PS Tool You can create a PowerShell and CSOM-based parameterised tool, which helps to port your documents from network file shared source location to O365 - SharePoint Online Document Library along with a set of metadata and content type.


Source Code

Below is the source code to achieve the same.

[string] $CTName = "CTAR",
[string] $SiteURL = "https://<;tenant url>",
[string] $DocLibName = "Documents",
[string] $User = "amjad@<tenant url>",
[string] $Folder = "D:\FilesToUpload"
#Add references to SharePoint client assemblies and authenticate to Office 365 site - required for CSOM
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
$Password = Read-Host -Prompt "Please enter your password" -AsSecureString
#Param Messages
Write-Host "Document Library :" $DocLibName
Write-Host "Destination Site URL :" $SiteURL
#Bind to site collection
$Context = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Creds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($User,$Password)
$Context.Credentials = $Creds
Write-Host "Credentials verified successfully!!"
Write-Host "In Progress.."
#Retrieve list
$List = $Context.Web.Lists.GetByTitle($DocLibName)
Write-Host "Document Library found"
#Upload file
Foreach ($File in (dir $Folder -File))
$FileStream = New-Object IO.FileStream($File.FullName,[System.IO.FileMode]::Open)
$FileCreationInfo = New-Object Microsoft.SharePoint.Client.FileCreationInformation
$FileCreationInfo.Overwrite = $true
$FileCreationInfo.ContentStream = $FileStream
$FileCreationInfo.URL = $File
$Upload = $List.RootFolder.Files.Add($FileCreationInfo)
Write-Host "In Progress."
$item = $Upload.ListItemAllFields
Write-Host "File name "$File" have been uploaded successfully!!"
$item["Title"] = $File.BaseName
foreach($ct in $List.ContentTypes)
if($ct.Name.ToUpper() -eq $CTName.ToUpper())
write-host $ct.Name -Foregroundcolor Green
write-host $ct.ID -Foregroundcolor Red
$newCTID = $ct.ID
#Association of content type with uploading item
Write-Host "CT ID: " $newCTID -Foregroundcolor Yellow
$item["ContentTypeId"] =$newCTID
Write-Host "Item is inserted to destination list successfully!!"
Write-Host "Completed uploading"

This is the solution to bring your files to O365 SharePoint Online document library.