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.
Facing issues? Have Questions? Post them here! I am happy to answer!
More Posts related to sharepoint,
- Change SharePoint Online List Experience to New Experience from Classic
- Cannot load PowerApps form in SharePoint Online due to repeated authentication
- Create SharePoint list from Excel spreadsheet and import table
- [Solved] SharePoint Search Internal server error exception
- [Fix] SharePoint: This embed code doesnt seem to work. We only support iframe based embeds
- How to extend retiring SharePoint 2010 Workflows and continue with Office 365
- SharePoint Online: Editing session has ended Message
- SharePoint error cannot connect to the configuration database
- That did'nt work, Issue type User not in directory - SharePoint external access error
- How to embed web page in SharePoint
- SharePoint - The URL is invalid. It may refer to a nonexistent file or folder, or refer to a valid file or folder that is not in the current Web.
- SharePoint error 2130575251 - The security validation for this page is invalid and might be corrupted
- Microsoft 365: How to Turn Off Delve in SharePoint Online for All Users
- SharePoint Server 2016 error Microsoft Office Online Server 2016 cant be installed on the same machine as a Microsoft SharePoint Server product
- JSON column formatting to preview SharePoint Online file on mouse hover
- How to show Videos on SharePoint Page
- How to get SharePoint Online user details from person or group column using REST API
- How to retrieve all SharePoint Online List Items using Rest API
- How to wrap column text in SharePoint Online Modern List Grid View using JSON formatting
- Recommended size and resolution for SharePoint Online Site logo
- SharePoint List redirect user after submitting form NewForm.aspx
- Add Custom External Link to SharePoint Site Navigation
- Drag drop files here option missing for SharePoint document library
- Can Microsoft SharePoint Lists be synced and accessed offline without internet?
- SharePoint - Use Today's Date Time in list view filter and calculated column
More Posts:
- How to save a file as csv in Windows Notepad? - Microsoft
- Mac: How to Insert a Row in Excel - Microsoft
- How to recover SharePoint FARM if the SQL Server IP changes - SharePoint
- Fetch More then 10 Links Per Page in Google Search Result - Google
- Python: How to Save Image from URL - Python
- How to Clear Gradle Cache on Mac - Gradle
- Quick steps to install Nginx on Ubuntu Linux - Ubuntu
- Get Button Text onClick Android App - Android