我正在尝试使用 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
之前有没有人尝试过这个/任何想法是否可以使用 执行上传到 OneDrive start-bitstransfer
?