copy BITS powershell

How to copy files with BITS using PowerShell?

If you use local (and global) networks, you might know that files between systems are transferring by using SMB, FTP or HTTP protocols. The problem with all of these protocols is difficulties with the large files downloading. Also, this sort of problem is a common issue due to slow or unstable connection. When you copy files through these protocols, usually it takes all available bandwidth between the server and users. It may cause a poor network or applications performance (sometimes we cannot set up the proper QoS policies).

In this article, we will show you an alternative way to copy the large files with the BITS protocol using PowerShell.

Using BITS

BITS or Background Intelligent Transfer Service is a Windows service for transferring files between the systems. With the BITS protocol, you can transfer files between computers (download and upload files).

Benefits of using BITS:

  • BITS is an intelligent protocol, which can regulate the bandwidth usage. BITS can dynamically change the data transferring speed
  • File transferring is running in the background, so it is invisible for user
  • BITS can resume file transferring automatically even after network interruptions
  • BITS does not require a full-scale IIS server on the client (or server) side

So, BITS is the best protocol for transferring large files over slow networks.

How to download the BITS protocol using PowerShell

Let’s suppose that we need to download the file, which is stored on the HTTP server (

First, we have to add BITS module support to the PowerShell:

Import-Module BitsTransfer

After that, we can see the list of all available commands:

get-command *-BITS*

powershell BITS

As we can see, there are eight scripts are available.

Synchronous data transfer through BITS

To download the file with the BITS protocol, use the command:

Start-BitsTransfer –source -destination c:\temp

powershell BITS transfer

Message This is a file transfer that uses the Background Intelligent Transfer service (BITS) says that the file is downloading right now with BITS protocol.

In this case, the script is begun downloading in synchronous mode. You can see the progress bar, which will show you a transferring status.

Note. If you want to restart your computer, you have to know, that the downloading process will not be renewed.

Asynchronous data transfer through BITS

You can run the process in the asynchronous mode. To do this you need to add the –asynchronous parameter in the command below. In this mode, if something happens (reboot the server, the client) the downloading process will automatically continue afterwards.

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

powershell source

But in this mode we cannot see the transferring status, so we should use the Get-BitsTransfer command to check the status.

Get-BitsTransfer | fl

powershell get BITS transfer

Also, you can check status in a tabular form:

Get-BitsTransfer | select DisplayName, BytesTotal, BytesTransferred, JobState | Format-Table –AutoSize

When you are using the asynchronous mode, it creates a temporary file (.tmp). To convert this file to the original file, use the command:

Get-BitsTransfer | Complete-BitsTransfer

complete BITS transfer

After that, the downloading process will be done, and you will see it in the list.

If the server requires user authentication, use the following command to open an authentication window:

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

powershell credential request

To make the process of result tracking easier, you can use a simple script that monitors the status and displays the transferring percentage on the screen.

After transferring, the script will convert the file to its original format:

Import-Module BitsTransfer
$job = Start-BitsTransfer -Source -Destination c:\temp -Asynchronous
while( ($job.JobState.ToString() -eq ‘Transferring’) -or ($job.JobState.ToString() -eq ‘Connecting’) )
Write-host $Job.JobState.ToString()
$Pro = ($job.BytesTransferred / $job.BytesTotal) * 100
Write-Host $Pro “%”
Sleep 3
Complete-BitsTransfer -BitsJob $job

Copying the contents of the directory through BITS

As we said earlier, the BITS protocol does not require a full-scale IIS server. That means, that we can copy files directly from others Windows machines or shared folders:

Start-BitsTransfer -Source \\msk-rep01\os\rhel-server-7.0-x86_64-dvd.iso -Destination c:\temp –Asynchronous

BITS cannot recursively copy files and folders from a specific directory. To copy all files with subfolders from the specific network directory, you should use this script:

Import-Module BitsTransfer
$folders = Get-ChildItem -Name -Path $source -Directory -Recurse
$job = Start-BitsTransfer -Source $Source\*.* -Destination $Destination -asynchronous -Priority low
while( ($job.JobState.ToString() -eq ‘Transferring’) -or ($job.JobState.ToString() -eq ‘Connecting’) )
Sleep 3
Complete-BitsTransfer -BitsJob $job
foreach ($i in $folders)
$exists = Test-Path $Destination\$i
if ($exists -eq $false) {New-Item $Destination\$i -ItemType Directory}
$job = Start-BitsTransfer -Source $Source\$i\*.* -Destination $Destination\$i -asynchronous -Priority low
while( ($job.JobState.ToString() -eq ‘Transferring’) -or ($job.JobState.ToString() -eq ‘Connecting’) )
Sleep 3
Complete-BitsTransfer -BitsJob $job

powershell BITS job

That is all, guys. BITS is an excellent alternative to traditional transferring through well-known protocols. BITS is the optimal solution for transferring the large files (like ISO files), so try it out.

You may also like:

Add Calendar Permissions in Office 365 via PowerSh... This is a tutorial on how to add calendar permissions in Office 365 for your users via PowerShell. You can add the permissions on a specific user’s ma...
How to Get List of Installed Programs in Windows 1... In this simple guide, we will show you two different ways of how to get a list of installed programs in Windows 10, 8 or Windows 7 using built-in comm...
Fix Trust relationship failed issue without domain... In this article, we will discuss the causes of Trust relationship failed error and some solutions on how to restore secure channel between the worksta...
Removing Old and Unused Drivers from Driver Store ... Each time you install or update your device driver, Windows OS (since Vista) continues to store the old version of the driver in the system Driver Sto...
Time Configuration for a Virtualized Domain Contro... Today we will talk about some of the features of time configuration on a virtualized domain controllers. Typically, the time synchronization scheme in...
  1. Posted by Cody
  2. Posted by Alexey Goroshinskiy
  3. Posted by Ioannis

Add Your Comment