可以通过PowerShell同时运行BITS传输吗?

时间:2015-09-03 20:18:46

标签: powershell microsoft-bits

我很高兴地承认我在PowerShell方面并不是非常流利。我设法找到了我需要做的一个例子,并根据我的需要调整它。代码如下。我想知道的是,我是否可以进行任何更改,以便在不同的PowerShell实例中调用脚本时,所有传输都会同时运行。

$Job = Read-Host "Enter a name for this transfer job."
$Destination = Read-Host "Enter the full UNC path for the destination."
$Source = Read-Host "Enter the full path for the file to be transferred."

import-module bitstransfer
Start-BitsTransfer -Destination $Destination -Source $Source -Asynchronous -DisplayName $Job -Authentication NTLM -Credential (Get-Credential) -Priority Normal -RetryTimeout 60 -RetryInterval 120 -TransferType Upload

$bits = Get-BitsTransfer -Name $Job

while ($bits.JobState -eq "Transferring" -or $bits.JobState -eq "TransientError" -or $bits.JobState -eq "Connecting" -or $bits.jobstate -eq "Error"  -and $pct -ne 100){
if ($bits.jobstate -eq "Error"){
    Resume-BitsTransfer -BitsJob $bits
}

$pct = ($bits.BytesTransferred / $bits.BytesTotal)*100
Cls
Write-Host "Percent complete: $pct" 
Start-Sleep 5}'

0 个答案:

没有答案