How to automatically upload/download files to/from Office 365 SharePoint Online

How to automatically upload/download files to/from Office 365 SharePoint Online

21941.zip
 
 
 
 
 
4.5 Star
(4)
5,615 times
Add to favorites
Office 365
12/17/2014
E-mail Twitter del.icio.us Digg Facebook
Sign in to ask a question


  • Get-SPOFile seems to have broken on 4/17
    1 Posts | Last post April 24, 2019
    • We have a script that has been running for months now, but it just stopped working last week. It now throws a WriteErrorException. Can't figure out why.
      
      Tried on a different server and got the same error.
      
      Anybody else having this problem?
  • Thanks
    1 Posts | Last post February 22, 2019
    • I was able to use part of your script for my own purposes. Thanks!
      
      I wanted to give you 5* but the system doesn't seem to be working :/
  • Getting Error:- new-object : Constructor not found. Cannot find an appropriate constructor for type System.IO.FileInfo.
    2 Posts | Last post July 23, 2018
    • I am using the function Get-SPOFile but getting the error:-
      
      Getting Error:- new-object : Constructor not found. Cannot find an appropriate constructor for type System.IO.FileInfo.
      
      I did replace '//' with '/' as mentioned by Bart Hoofd, but it doesn't work.
      
      Any comments?
    • Same here.
  • Is there a resolution for list view threshold with this script using SharePoint online?
    1 Posts | Last post April 12, 2018
    • I'm hitting list threshold.
      
      PS C:\help> Get-SPOFolder -downloadPath "C:\Help" -userName test.user@example.onmicrosoft.com.com -siteURL "https://example.sharepoint.com/dt" -ListName HelpRepository -FolderName "Help (Master)"
      
      cmdlet Get-SPOFolder at command pipeline position 1
      Supply values for the following parameters:
      Password: ****************
      Conntect To Sharepoint Site https://example.sharepoint.com/dt
      Get-SPOFolder : Exception calling "ExecuteQuery" with "0" argument(s): "The attempted operation is prohibited because
      it exceeds the list view threshold enforced by the administrator."
      At line:1 char:1
      + Get-SPOFolder -downloadPath "C:\Help" -userName test.user@example.onmicrosoft.com -siteURL ...
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : NotSpecified: (:) [Get-SPOFolder], MethodInvocationException
          + FullyQualifiedErrorId : ServerException,Get-SPOFolder
      
  • upload function not working
    1 Posts | Last post February 26, 2018
    • Upload file test.txt
      Exception calling "SaveBinaryDirect" with "4" argument(s): "Specified argument was out of the range of valid values.
      Parameter name: serverRelativeUrl"
      At C:\Users\kaush\Desktop\HWNS\Test\21941\PowerShell\SPOUploadDownload.psm1:109 char:9
      +         [Microsoft.SharePoint.Client.File]::SaveBinaryDirect($Context ...
      +         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
          + FullyQualifiedErrorId : ArgumentOutOfRangeException
      
      
      Please help urgent
  • Not able to download file
    1 Posts | Last post December 19, 2017
    • Hi
      Anything iam doing wrong with the below params?. I cant download from Sharepoint 365
      
      Get-SPOFile  -downloadPath "D:\ddd" -userName rajkumar@x.com -siteURL "https://x.sharepoin
      t.com/xxx/Shared Documents/" -ListName Documents -FolderName ABC  -FileName "Save.txt"
      
      Get-SPOFile : Exception of type
      'Microsoft.PowerShell.Commands.WriteErrorException' was thrown.
      At line:1 char:1
      + Get-SPOFile  -downloadPath "D:\ddd" -userName
      user@team ...
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      ~~~
          + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorExcep
         tion
          + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorExceptio
         n,Get-SPOFile
  • download everything?
    1 Posts | Last post December 14, 2017
    • Can this script be used to download everything within 'shared documents' for instance?
      
      I have it working for downloading individual files, but it doesn't like wildcards.
      
      Also having issues with folder download:
      Get-SPOFolder -downloadPath "C:\documents" -userName jp.matthew@'****'.com -siteURL "https://'****'.sharepoint.com/" -ListName "Shared Documents" -FolderName "2013 Sports"
      
      cmdlet Get-SPOFolder at command pipeline position 1
      Supply values for the following parameters:
      Password: *********
      Conntect To Sharepoint Site https://'****'.sharepoint.com/
      Get-SPOFolder : Exception calling "ExecuteQuery" with "0" argument(s): "Invalid URI: The hostname could not be parsed."
      At line:1 char:1
      + Get-SPOFolder -downloadPath "C:\documents" -userName jp.matthew@'****'...
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : NotSpecified: (:) [Get-SPOFolder], MethodInvocationException
          + FullyQualifiedErrorId : ServerException,Get-SPOFolder
      
      I have tried various differnt urls but that's the one that works for single file downloads,
      any help would be great thanks
  • Script no longer working?
    2 Posts | Last post November 15, 2017
    • I was very enthousiastic when finding this solution, but trying to get it to work is difficult. I've tried on Windows 2008 R2 with WMF 3.0 correcting to an up-to-date SharePoint Online environment.
      
      new-object : Constructor not found. Cannot find an appropriate constructor for type System.IO.FileInfo.
      At \\xxxxx.local\Maintenance\ADMHome\ADMBHoofd\SPO file upload test\PowerShell\SPOUploadDownload.psm1:491 char:19
      +             $fi = new-object System.IO.FileInfo($fileurl)
      +                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : ObjectNotFound: (:) [New-Object], PSArgumentException
          + FullyQualifiedErrorId : CannotFindAppropriateCtor,Microsoft.PowerShell.Commands.NewObjectCommand
    • The issue was that the final $fileurl contained a double slash (e.g. //Library/File.txt). I fixed that issue by adding the following line in Function Get-SPOFile:
      
                  $fileurl = $fileurl.Replace('//','/')   # Replace double /
      
      in the code part:
      
                  if($FolderName -ne "")
                  {
                      $fileurl = $Web.ServerRelativeUrl + "/" + $ListName + "/" + $FolderName + "/" + $FileName
                  }
                  else
                  {
                      $fileurl = $Web.ServerRelativeUrl + "/" + $ListName + "/" + $FileName
                  }
                  $fileurl = $fileurl.Replace('//','/')   # Replace double /
                  $file = $web.GetFileByServerRelativeUrl($fileurl)
  • Another error
    4 Posts | Last post October 17, 2017
    • ListName: "Shared Documents"
      Upload file test.docx
      Exception calling "SaveBinaryDirect" with "4" argument(s): "Specified argument was out of the range of valid values.
      Parameter name: serverRelativeUrl"
      At C:\Users\ivo\Downloads\21941 (1)\PowerShell\SPOUploadDownload.psm1:109 char:9
      +         [Microsoft.SharePoint.Client.File]::SaveBinaryDirect($Context, $targetPa ...
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
          + FullyQualifiedErrorId : ArgumentOutOfRangeException
      
      PS C:\Windows\system32>
    • Hey guys, any hint as to what's wrong? Will you be updating the script or should I change something in the way I'm using it?
    • Any update?
    • I had to update line 92 from
      $ParentURL = Split-Path $targetPath
      to
      $ParentURL = Split-Path $siteURL
  • User/Credential Restriction?
    1 Posts | Last post September 21, 2017
    • We run Sharepoint Online and login with our standard windows credentials; I think this means we have a federated login with our work credentials. I'm able to use these credentials to get a directory listing. However, when I try using the script with an externally invited user it doesn't seem to work. This error occurs:
      
      Get-SPOFolder -downloadPath "C:\temp" -userName <user>@outlook.com -siteURL "https://<work>.sharepoint.com/sites/<site>" -ListName Documents -FolderName "<folder>"
      
      cmdlet Get-SPOFolder at command pipeline position 1
      Supply values for the following parameters:
      Password: ********************
      Get-SPOFolder : Exception of type 'Microsoft.PowerShell.Commands.WriteErrorException' was thrown.
      At line:1 char:1
      + Get-SPOFolder -downloadPath "C:\temp" -userName <user>@outlook.com -site ...
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
          + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Get-SPOFolder
1 - 10 of 19 Items