通过BITS上传到OneDrive

时间:2015-11-26 09:15:18

标签: powershell file-upload onedrive powershell-v4.0 microsoft-bits

我正在尝试使用BITS向OneDrive提交文件。 我在这里找到了一篇文章:https://msdn.microsoft.com/en-us/library/dn858877.aspx;但我希望PowerShell的原生Start-BitsTransfer方法可以为我节省一些力气。然而,该文章暗示OneDrive支持BITS上传;事情很有希望。

$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

当我运行上面的代码时,会弹出进度条,然后会出现错误。完整输出(包括凭证提示)如下:

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

有没有人在尝试使用start-bitstransfer之前是否有可能使用{{1}}上传到OneDrive?

1 个答案:

答案 0 :(得分:1)

您似乎正在尝试上传到OneDrive for Business。您找到的MSDN文章适用于个人OneDrives; OneDrive for Business不支持BITS。虽然您无法使用Start-BitsTransfer,但您可以找到有关新上传API here的信息,该信息适用于个人和企业OneDrives。