1

I readily admit I'm not incredibly fluent in PowerShell. I managed to find an example of what I need to do and tweak it mostly to my needs. The code is below. What I'd like to know is, are there any changes I can make so that if I were to invoke the script in different instances of PowerShell then all the transfers run at the same time.

$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}'
infinit_e
  • 57
  • 1
  • 10

0 Answers0