1

私が 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}'
4

0 に答える 0