1

我正在嘗試使用BITS將文件提交到OneDrive。 我在這找到一篇文章:https://msdn.microsoft.com/en-us/library/dn858877.aspx;但我希望PowerShell的本地Start-BitsTransfer方法可以爲我節省一些工作量。但該文章暗示OneDrive支持BITS上傳;所以事情很有希望。通過BITS上傳到OneDrive

$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到OneDrive?

+0

如果您像'Start-BitsTransfer -Credential user @ domain.com'手動輸入信譽,那麼您應該提示輸入密碼,之後您是否會收到相同的錯誤? – Avshalom

+0

@Avshalom是的,遺憾地傳遞一個憑證變量或讓'Start-BitsTransfer'命令行提示輸入密碼導致相同的結果。 – JohnLBevan

+1

@JohnLBevan我不認爲這會起作用,OneDrive預計OAuth承載令牌,一種不受'Start-BitsTransfer'支持的認證方案 –

回答

1

看起來您嘗試上傳到OneDrive for Business。您找到的MSDN文章適用於個人OneDrives; OneDrive for Business不支持BITS。儘管您無法使用Start-BitsTransfer,但您可以找到關於新的上傳API的here的信息,這些信息適用於個人和企業OneDrives。