1

I'm trying to submit a file to OneDrive using BITS. I found an article on this here: https://msdn.microsoft.com/en-us/library/dn858877.aspx; but I was hoping PowerShell's native Start-BitsTransfer method could save me some effort. However that article implies that OneDrive supports BITS uploads; so things are promising.

$source = '\\myFileServer\Backups\SqlServerDbBackup.bak' #3.2GB file
$destination = 'https://myCompany.sharepoint.com/personal/my_account/Documents/SqlServerDbBackup.bak'
$cred = get-credential #here I enter the same credentials I use to access the site
Start-BitsTransfer -Source $source -Destination $destination -TransferType Upload -Credential $cred

When I run the above code the progress bar briefly pops up, then an error appears. Full output (including credentials prompt) below:

cmdlet Get-Credential at command pipeline position 1
Supply values for the following parameters:
Start-BitsTransfer : HTTP status 501: The server does not support the functionality required to fulfill the request.
At line:8 char:1
+ Start-BitsTransfer -Source $source -Destination $destination -TransferType Uploa ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Start-BitsTransfer], Exception
    + FullyQualifiedErrorId : StartBitsTransferCOMException,Microsoft.BackgroundIntelligentTransfer.Management.NewBitsTransferCommand

Has anyone attempted this before / any ideas whether it's possible to perform an upload to OneDrive using start-bitstransfer?

JohnLBevan
  • 22,735
  • 13
  • 96
  • 178
  • if you enter creds manually like `Start-BitsTransfer -Credential user@domain.com` you should be prompted for password, after that do you get the same error? – Avshalom Nov 26 '15 at 10:52
  • @Avshalom Yes, sadly passing a credentials variable or getting the `Start-BitsTransfer` commandlet to prompt for password results in the same outcome. – JohnLBevan Nov 26 '15 at 11:11
  • 1
    @JohnLBevan I don't think it's going to work, OneDrive expects an OAuth bearer token, an authentication scheme not supported by `Start-BitsTransfer` – Mathias R. Jessen Nov 26 '15 at 13:57

1 Answers1

1

It looks like you're trying to upload to OneDrive for Business. The MSDN article you found applies to personal OneDrives; BITS isn't supported in OneDrive for Business. Although you can't use Start-BitsTransfer, you can find info about the new upload API's here, which work for both personal and business OneDrives.

daspek
  • 1,414
  • 1
  • 10
  • 10