Upload new document version, PS | WF

Leandro Figueira 1 Reputation point
2021-04-29T13:19:00.363+00:00

Dear,

How can I upload a new version of a document to a SharePoint 2013 library without using the visual interface?

For PowerShell or Workflow 2013, would it be possible or would it be necessary to develop a solution in C #?

SharePoint Workflow
SharePoint Workflow
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Workflow: An orchestrated and repeatable pattern of business activity, enabling data transformation, service provision, and information retrieval.
545 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. MichaelHan-MSFT 18,021 Reputation points
    2021-04-30T01:39:19.58+00:00

    Hi @Leandro Figueira ,

    You could achieve this using powershell. Please refer to this article: How to Upload File to SharePoint Library using PowerShell?

    Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue   
       
    #Function to Upload File  
    Function Upload-File($WebURL, $DocLibName, $FilePath)  
    {  
        #Get the Web & Lists to upload the file  
        $Web = Get-SPWeb $WebURL  
        $List = $Web.GetFolder($DocLibName)   
       
        #Get the Files collection   
        $Files = $List.Files   
       
        #Get File Name from Path  
        $FileName = $FilePath.Substring($FilePath.LastIndexOf("\")+1)   
       
        #Delete the File from library, if already exist!  
        If($Files.Item($DocLibName +"/" + $FileName))  
        {  
            $Files.delete($DocLibName +"/" + $FileName)  
        }  
        #Get the File  
        $File= Get-ChildItem $FilePath  
       
        #Add File to the collection  
        $Files.Add($DocLibName +"/" + $FileName,$File.OpenRead(),$false)  
       
        #Dispose the objects  
        $web.Dispose()  
    }  
        
    #call the upload function  
    Upload-File "http://sharepoint.company.com" "Monthly Reports" "D:\Reports\LargeLists.txt"  
    

    If an Answer is helpful, please click "Accept Answer" and upvote it.
    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