Home / Solution / Copying Large Files over an Unreliable Network Using BITS and PowerShell

Copying Large Files over an Unreliable Network Using BITS and PowerShell

As a rule, in native and international networks, recordsdata are transferred between gadgets utilizing SMB, FTP or HTTP protocols. The downside of all these protocols is a few troubles with resuming the obtain of the big recordsdata, which may change into even worse if the community is sluggish or unreliable. Moreover, when copying recordsdata utilizing these protocols, all of the accessible bandwidth between a server and a recipient is used, which can negatively have an effect on the community efficiency and the operation of different community apps (it isn’t at all times potential to configure right QoS insurance policies on the community gear). In this text, we’ll contemplate how you can use BITS protocol and PowerShell to repeat giant recordsdata over a sluggish or unstable community.

BITS Protocol

BITS (Background Intelligent Transfer service) is a Windows service used to switch recordsdata between the methods. You can obtain and add recordsdata utilizing the BITS protocol. This protocol is utilized by computer systems when receiving recordsdata from servers when performing computerized Windows updates (together with when downloading updates from ), when receiving packages from SCCM distribution factors, and so forth.

Advantages of the BITS Protocol:

  • BITS is the clever protocol in a position to management the used bandwidth of the communication channel and to not have an effect on the operation of different community apps and companies. BITS can use solely the free (unallocated) bandwidth and dynamically change the info charge throughout the switch (if different functions enhance the community use, BITS consumer can scale back the info switch charge over the community);
  • File obtain can proceed within the background mode clear to the consumer;
  • BITS job in resume mode will robotically proceed even when the communication channel between the pc and the consumer is damaged, or after the pc is rebooted;
  • You can pause or resume downloading by BITS with out dropping information;

    Note. The means to renew file copying over the community can also be accessible within the robocopy.exe utility, which lets you resume downloading the file if the connection is misplaced.

  • BITS means that you can handle the priorities of obtain jobs;
  • File switch between computer systems happens on ports 80 (HTTP) or 443 (HTTPS), so that you received’t should open extra ports on firewalls. For instance, port 445, which is used when coping recordsdata over the SMB protocol (don’t neglect that there are various vulnerabilities in previous model of the );
  • A deployed IIS server isn’t essentially required on the BITS recipient and server facet.

Thus, BITS is the preferable protocol for transferring giant recordsdata over sluggish and unstable networks (satellite tv for pc channel, GPRS connection, and so forth.).

BITS: OS and PowerShell Version Requirements

BITS protocol appeared in Windows XP, during which bitsadmin.exe utility might be used to handle BITS duties. The utility continues to be supported, however is deprecated. To handle BITS jobs, it’s preferable to make use of particular PowerShell cmdlets.

To work below this state of affairs, you want an OS not lover than Windows Vista or Windows Server 2008 and and PowerShell 2.zero or newer. Modern variations of Windows 10 and Windows Server 2016/2012 R2 totally help BITS.

Tip. It is feasible to make use of Windows Server 2003 as effectively. In this case you’ll have to set up KB 923845 replace and PowerShell 2.zero.

BITS help is required on the facet of each consumer and server.

How to Download a File over the BITS Protocol utilizing PowerShell?

Suppose you wish to obtain a big ISO file saved on IIS HTTP server ( It is assumed that nameless entry is allowed to this URL (later we’ll contemplate entry to the URL with authentication).

First of all, import BITS module in your PowerShell session:

Import-Module BitsTransfer

After the module is imported, the listing of all accessible instructions could be displayed as follows:

get-command *-BITS*

As you may see, there are Eight cmdlets can be found:

  • Add-BitsFile
  • Complete-BitsTransfer
  • Get-BitsTransfer
  • Remove-BitsTransfer
  • Resume-BitsTransfer
  • Set-BitsTransfer
  • Start-BitsTransfer
  • Suspend-BitsTransfer

Synchronous File Transfer between Computer Using BITS

The Start-BitsTransfer cmdlet means that you can obtain recordsdata by way of HTTP(s) (just like the cmdlet) in addition to from community shared folders (by way of SMB). To obtain a file from the required URL utilizing the BITS protocol and reserve it to the native listing C:Temp, use the command:

Start-BitsTransfer –supply -destination c:temp

The message “This is a file switch that makes use of the Background Intelligent Transfer service (BITS)” signifies that the required file is being downloaded utilizing BITS.

In this case the cmdlet has began the obtain the ISO file in a synchronous mode. The obtain is much like a typical strategy of file copying by File Explorer or utilizing the Copy-Item cmdlet. A progress bar is displayed on the display screen, which displaying the obtain standing. If a pc is restarted, the obtain received’t be resumed (you’ll need to obtain the complete file once more).

Transferring Large Files Over the Network with BITS in Asynchronous Mode

BITS obtain could be began within the asynchronous mode as effectively. To do it, add –asynchronous parameter to the command proven above. In this mode, if one thing occurs (server or consumer reboot, interruption of the communication channel, and so forth.), the bits job will robotically resume after the supply is restored and the file obtain might be proceed from the second the connection is interrupted:

Start-BitsTransfer -source -destination c:temp -asynchronous

Important. By default, Start-BitsTransfer runs with Foreground precedence (the best potential one). It is meant that the obtain began on this mode will compete with different processes for the channel bandwidth. To keep away from it, you need to explicitly set another precedence as an argument of the command, e. g., -Priority low:

Start-BitsTransfer -source -destination c:temp -asynchronous -Priority low

The asynchronous BITS process runs within the background, and the file obtain course of isn’t displayed on the display screen. The standing of the BITS job could be obtained from the PowerShell console utilizing the Get-BitsTransfer command:

Get-BitsTransfer | fl

The command returns the switch standing (on this case the switch is over: Transferred), the data concerning the variety of bytes transferred, the entire file measurement, the time the file has been created and the time the duty is accomplished.

You can view the standing of all BITS duties operating on the pc in tableform:

Get-BitsTransfer | choose ShowName, BytesTotal, BytesTransferred, JobState | Format-Table -AutoSize

When utilizing the asynchronous switch mode, a brief file with TMP extension is created (by default, it’s hidden in Windows Explorer). To convert it into the supply file (which is saved on the supply server), run the command Complete-BitsTransfer:

Get-BitsTransfer | Complete-BitsTransfer

The BITS obtain process is then thought of full and faraway from the listing of jobs.

You can add a neighborhood file to a community shared folder on a distant Windows file server. To do that, use the next command (for comfort, you may specify the identify of the copy job):

Start-BitsTransfer -Source C:isow10_1809.iso -Destination manch-fs1iso -Asynchronous -ShowName CopyISOtoMan

To briefly droop a BITS process, run:

Get-BitsTransfer -Name CopyISOtoMan | Suspend-BitsTransfer

To resume the BITS job, use the Resume-BitsTransfer cmdlet:

Get-BitsTransfer -Name CopyISOtoMan | Resume-BitsTransfer -Asynchronous

You can add extra recordsdata to the BITS process utilizing the Add-BitsFile cmdlet:

Get-BitsTransfer -Name CopyISOtoMan | Add-BitsFile -Source C:isow10msu* -Destination manch-fs1iso -Asynchronous

To delete all BITS obtain duties on the pc (together with these began by different customers), run the next command:

Get-BitsTransfer -Allusers|Remove-BitsTransfer

You can’t cancel BITS jobs operating below System account (error 0x80070005 “Unable to cancel job”). To cancel such a process, you might want to execute the Remove-BitsTransfer command below SYSTEM.

If the server, the place the file is saved, requires consumer authentication, the next command will permit to point out a window to specify credentials to entry the useful resource:

Start-BitsTransfer -source -destination c:temp -asynchronous -Priority low -Authentication NTLM -Credential Get-Credential

To make it simpler to trace the outcomes of a BITS process, you need to use a easy script, which permits to trace the duty progress and as soon as each few seconds shows the obtain share on the display screen. After the obtain is over, the script robotically converts the TMP file into the supply format:

Import-Module BitsTransfer
$bitsjob = Start-BitsTransfer -Source -Destination c:temp -Asynchronous
whereas( ($bitsjob.JobState.ToString() -eq 'Transferring') -or ($bitsjob.JobState.ToString() -eq 'Connecting') )

Complete-BitsTransfer -BitsJob $bitsjob

How to Copy the Directory Contents Using BITS?

As we already advised, BITS doesn’t require a Web-server, and it signifies that we are able to copy recordsdata immediately from different Windows computer systems or community shared folders:

Start-BitsTransfer -Source lon-rep01osRHEL4.Eight-x86_64-AS-DVD.iso -Destination c:temp -Asynchronous

BitsTransfer can’t recursively copy all recordsdata and folders from a particular folder or recordsdata utilized by different packages. In order to repeat all recordsdata and subdirectories from the required community shared folder, use this script (you may first test whether or not the goal listing exists and create it):

Import-Module BitsTransfer
if ( -Not (Test-Path $Destination))

$folders = Get-BabyItem -Name -Path $supply -Directory -Recurse
$bitsjob = Start-BitsTransfer -Source $Source*.* -Destination $Destination -asynchronous -Priority low
whereas( ($bitsjob.JobState.ToString() -eq 'Transferring') -or ($bitsjob.JobState.ToString() -eq 'Connecting') )

Complete-BitsTransfer -BitsJob $bitsjob
foreach ($i in $folders)

How to Upload File on HTTP Server Using PowerShell and BITS?

With BITS, you can’t solely obtain a file from an HTTP server, but additionally add it to a distant net server. To do that, the IIS net server with the Bits Server Extension element have to be put in on the goal server. In the settings of the IIS digital listing within the Bits Uploads part, you might want to allow the “Allow shoppers to uploads recordsdata” choice.


If you utilize nameless authentication, you need to permit nameless customers to write down to the listing on the NTFS permissions stage. If file uploads are carried out below licensed customers, they should grant RW permissions to the add folder.

To add a file to an HTTP server utilizing the BITS protocol, run the next command:

Start-bits –supply c:isowinsrv2016.iso -destination –Transfertype Upload

Please word that by default IIS means that you can add recordsdata as much as 30 MB. To permit importing giant recordsdata, you might want to change the worth within the maxAllowContentLength parameter within the net.config file.

Thus, utilizing BITS options is a superb different to the frequent file copying over the community utilizing SMB protocol. BITS file switch process is carried out regardless of of connection disruptions or pc restarts, and doesn’t a lot occupy the bandwidth with out interfering with different apps. The BITS protocol could be the optimum answer for transferring giant ISO picture and digital machine recordsdata (vmdk, vhdx) over a WAN community.


Check Also

Fixing Windows Update and DISM Error 0x80073712 on Windows Server 2016/Windows 1…

I confronted an error code 0x80073712 when making an attempt to put in safety updates …

Leave a Reply

Your email address will not be published. Required fields are marked *