Copy local file to SharePoint

spjkk 40 Reputation points
2024-08-15T01:44:29.3333333+00:00

Is there any Windows or SharePoint PowerShell command for copying local files to SharePoint?

Microsoft 365 and Office | SharePoint | For business | Windows
0 comments No comments
{count} votes

Accepted answer
  1. AllenXu-MSFT 24,951 Reputation points Moderator
    2024-08-15T07:33:44.27+00:00

    Hi @spjkk,

    You can use Add-PnPFile to copy files from local to SharePoint Online.

    Here is an example:

    #Config Variables
    $SiteURL = "https://xxx.sharepoint.com"
    $SourceFilePath ="C:\Documents\xxx.docx"
    $DestinationPath = "Shared Documents" #Site Relative Path of the Library
     
      
    #Connect to PnP Online
    Connect-PnPOnline -Url $SiteURL -interactive
          
    #powershell pnp to upload file to sharepoint online
    Add-PnPFile -Path $SourceFilePath -Folder $DestinationPath
    
    
    

    Read more: SharePoint Online: Upload Files to Document Library using PowerShell.


    If the answer is helpful, please click "Accept as Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.