Simple Download PowerShell Script From A SP Online Library

Introduction 

 
Hi guys, let's explore the smoothest and easiest way to upload all the files present in your local desktop path to a SharePoint online library.
 
We need to install a few NuGet package installations to avoid unnecessary errors by running the below scripts.
 
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Install-PackageProvider -Name NuGet
Install-Module -Name SharePointPnPPowerShellOnline
 
Here is the downloading PnP script to run. You need to do the configurations accordingly.
  1. $O365ServiceAccount = "veera.kaveri@xyz.com"  
  2. $O365ServiceAccountPwd = "xyz@12345678"  
  3. $SharePointSiteURL = "https://xyzeur.sharepoint.com/sites/S022-013-IS/TestMigration"  
  4. # Change this SharePoint Site URL  
  5. $SharedDriveFolderPath = "C:\Users\23594\Downloads\DemoLibFiles"  
  6. # Change this Network Folder path  
  7. $SharePointFolderPath = "DemoLibrary"  
  8. Connect - PnPOnline - Url $SharePointSiteURL - UseWebLogin  
  9. $Files = Get - PnPFolderItem - FolderSiteRelativeUrl $SharePointFolderPath - ItemType File  
  10. foreach($File in $Files) {  
  11.     Get - PnPFile - Url $File.ServerRelativeUrl - Path $SharedDriveFolderPath - FileName $File.Name - AsFile  
  12. }  
Here is the output, as shown below.
 
Simple Download PowerShell Script From A SP Online Library
 
Simple Download PowerShell Script From A SP Online Library 
Download Speed for 1k Dummy Files: 1.86 GB/9 Mins = 0.18 GB/Min
 
Note
The above speeds can vary wrt to the LAN/Wi-Fi Connection too!!
 
The above PnP script is useful for our business requirement and can be programmed to be automated by calling it into other programs, or via Azure web jobs/Azure functions, etc.
 
Cheers!!