Uploading folders in sharepoint from powershell

Welcome Forums General PowerShell Q&A Uploading folders in sharepoint from powershell

Viewing 2 reply threads
  • Author
    Posts
    • #278094
      Participant
      Topics: 2
      Replies: 1
      Points: 25
      Rank: Member

      My below code successfully read a folder and uploades the subfolder one by one as a zip file in SharePoint. But if any of my file is of Zip extension, it gives me an error. I would like to know how can I fix my existing code below to handle the zip files as well so that it loads both the zip folder and non-zip files and folders in the SharePoint. I tried multiple tings like removing .zip extension in the Create-Archive and file but it does not work. error received:

      2020-12-09T15:49:05.7979920Z Invoke-RestMethod : The remote server returned an error: (400) Bad Request. 2020-12-09T15:49:05.7981233Z At D:\a\r1\a_DevOpsScripts\ReleaseNoteScripts\UploadInSharePoint.ps1:55 char:17 2020-12-09T15:49:05.7982104Z + … $response = Invoke-RestMethod $uploadURLObject.uploadUrl -Method ‘PUT … 2020-12-09T15:49:05.7982819Z + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2020-12-09T15:49:05.7983312Z + CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebExc 2020-12-09T15:49:05.7983979Z eption 2020-12-09T15:49:05.7984369Z + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

       

       

    • #278154
      Participant
      Topics: 10
      Replies: 203
      Points: 996
      Helping Hand
      Rank: Major Contributor

      If your server has enabled WebDAV, have you tried robocopy? I have done that in the past. Also, make sure someone has not configured the server to block ZIP file types.

      https://www.sharepointdiary.com/2013/12/blocked-file-types-in-sharepoint-2013.html

      This is version dependent. The latest version of SP does not block any types by default.

    • #278181
      Participant
      Topics: 2
      Replies: 1
      Points: 25
      Rank: Member

      @TonyD05, nothing is blocked, I am able to create and upload zip file in SharePoint from other services, it seems the zip is already an archive and hence converting an archive to an archive is not something we should do, it works fine for non.zip files. now i am looking for a way where i can directly upload the zip without creating an archive. Hope you get my point. Problem is I am unable to call the file directly here

Viewing 2 reply threads
  • You must be logged in to reply to this topic.