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.
- $O365ServiceAccount = "[email protected]"
- $O365ServiceAccountPwd = "xyz@12345678"
- $SharePointSiteURL = "https://xyzeur.sharepoint.com/sites/S022-013-IS/TestMigration"
- # Change this SharePoint Site URL
- $SharedDriveFolderPath = "C:\Users\23594\Downloads\DemoLibFiles"
- # Change this Network Folder path
- $SharePointFolderPath = "DemoLibrary"
- Connect - PnPOnline - Url $SharePointSiteURL - UseWebLogin
- $Files = Get - PnPFolderItem - FolderSiteRelativeUrl $SharePointFolderPath - ItemType File
- foreach($File in $Files) {
- Get - PnPFile - Url $File.ServerRelativeUrl - Path $SharedDriveFolderPath - FileName $File.Name - AsFile
- }
Here is the output, as shown below.
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!!