Overall process consists of three steps: First step is to connect to SharePoint Online Site Collection
$credentials = Get-Credential Connect-PnPOnline -Url $siteUrl -CreateDrive -Credentials $credentials
(dir $path -Recurse) | %{ try{ if($_.GetType().Name -eq "FileInfo"){ $SPFolderName = $documentLibraryName + $_.DirectoryName.Substring($path.Length); . . . .
$file = Get-ChildItem -Path $LocalFolderLocation -Recurse $i = 0; Write-Host "Uploading documents to Site.." -ForegroundColor Cyan (dir $path -Recurse) | %{ try{ $i++ if($_.GetType().Name -eq "FileInfo"){ $SPFolderName = $documentLibraryName + $_.DirectoryName.Substring($path.Length); $status = "Uploading Files :'" + $_.Name + "' to Location :" + $SPFolderName Write-Progress -activity "Uploading Documents.." -status $status -PercentComplete (($i / $file.length) * 100) $te = Add-PnPFile -Path $_.FullName -Folder $SPFolderName } } catch{ } }