PowerShell Script to upload file to SharePoint
$localFilePath = "D:\Annual Report\report-2023.xlsx"
if (-not (Get-Module -Name SharePointPnPPowerShellOnline -ListAvailable)) {
Install-Module SharePointPnPPowerShellOnline -Force
}
$siteUrl = "https://your-tenant-name.sharepoint.com/sites/your-site-name"
Connect-PnPOnline -Url $siteUrl
$destinationLibrary = "Shared Documents"
Add-PnPFile -Path $localFilePath -Folder $destinationLibrary -NewFileName "report-2023.xlsx"
Disconnect-PnPOnline
Note that we are installing SharePoint PnP PowerShell module if not already installed using the script and uploading report-2023.xlsx from local D: drive to the SharePoint Shared Documents folder.
Do replace you tenent information in the siteURL.
Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!