Windows OS Hub
  • Windows
    • Windows 11
    • Windows Server 2022
    • Windows 10
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
  • PowerShell
  • Linux
  • Home
  • About

Windows OS Hub

  • Windows
    • Windows 11
    • Windows Server 2022
    • Windows 10
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
  • PowerShell
  • Linux

 Windows OS Hub / PowerShell / Downloading (Transferring) Large Files Using PowerShell and BITS

April 10, 2024 PowerShellWindows 10Windows 11Windows Server 2019

Downloading (Transferring) Large Files Using PowerShell and BITS

If you need to download (transfer) a large file to a remote computer without overloading the network channel, we recommend using the BITS protocol. BITS (Background Intelligent Transfer service) is a built-in Windows service for transferring files between computers that supports: asynchronous transfers, can run in the background, can resume interrupted downloads, and can dynamically change download/upload speeds to avoid overloading the network connection. Thus, BITS allows you to efficiently transfer large files over an unstable or slow network without affecting the performance of other network apps. In this article, we’ll look at how to use PowerShell to download and transfer big files between computers using the BITS protocol.

Contents:
  • How to Download Files with PowerShell and BitsTransfer Module
  • Asynchronous Resumable File Transfers via BITS
  • Managing BITS File Transfer Jobs with PowerShell

How to Download Files with PowerShell and BitsTransfer Module

To manage BITS jobs on Windows, you can use the built-in PowerShell BitsTransfer module. Download an ISO image file from the IIS web server using the BITS protocol:

Start-BitsTransfer –source http://testsite.woshub.loc/netinst.iso -destination c:\temp

Start-BitsTransfer transfer file using PowerShell

The BITS client synchronously downloads the file and saves it to the specified local directory. A bar will appear on the screen to indicate the download progress. The file transfer will not resume if a connection is lost (you will need to download the whole file again). Transferring a file in this mode is similar to downloading a file from a website using Invoke-WebRequest.

Asynchronous Resumable File Transfers via BITS

To download files via BITS in asynchronous mode (supporting resumed downloads), you need to add the -asynchronous parameter

Start-BitsTransfer –source http://testsite.woshub.loc/netinst.iso -destination c:\temp  -asynchronous

download file via bits in async mode

If the connection is lost or the source or destination reboots, the asynchronous BITS job will automatically resume.

By default, the BITS job will use all of the available bandwidth on the network channel (foreground mode). To make the BITS job use only unused network link bandwidth, add the -Priority low parameter. In this case, the BITS download task will not compete for the transmission channel bandwidth with any other network service.

Managing BITS File Transfer Jobs with PowerShell

To check the status of background BITS download jobs, run:

Get-BitsTransfer | fl

View BITS job file transfer status

The command returns the file transfer status, information on the number of bytes transferred, the total file size, the creation time, and the completion of the BITS job.

View the status of all BITS background jobs on your computer:

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

You need to run the following command after the BITS file download job has finished:

Get-BitsTransfer| where JobState -eq 'Transferred'| Complete-BitsTransfer

If you do not do this, the BITS client will not automatically rename the temporary file with a .TMP extension in the destination directory to its original filename.

Complete-BitsTransfer

BITS allows you to transfer files not only over HTTP, but also over the standard Windows SMB file-sharing protocol. If you want to copy a file to the C$ admin share on a remote computer or to a shared network folder, you will need to specify the UNC path:

Start-BitsTransfer -Source C:\iso\win2022.iso -Destination \\man-srv01\c$\iso -Asynchronous -DisplayName CopyISOtoMan

The BITS job can be paused:

Get-BitsTransfer -Name CopyISOtoMan | Suspend-BitsTransfer

Resume file download:

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

If you need to authenticate to a remote server to access a file:

Start-BitsTransfer -source http://10.1.1.18/erd65_32.iso -destination c:\temp -asynchronous -Priority low -Authentication NTLM -Credential Get-Credential

BITS transfer with NTLM Auth

To track the status of a large file download job, use the following PowerShell script. The percentage of completion of the download will be displayed on the screen, and when the task is complete, the TMP file will be renamed back to its original name.

Import-Module BitsTransfer
$bitsjob = Start-BitsTransfer -Source http://10.1.1.18/erd65_32.iso -Destination c:\temp -Asynchronous
while( ($bitsjob.JobState.ToString() -eq 'Transferring') -or ($bitsjob.JobState.ToString() -eq 'Connecting') )
{
Write-host $bitsjob.JobState.ToString()
$Proc = ($bitsjob.BytesTransferred / $bitsjob.BytesTotal) * 100
Write-Host $Proc “%”
Sleep 3
}
Complete-BitsTransfer -BitsJob $bitsjob

The BITS protocol is widely used for background file transfers on Windows networks. This protocol is used to download Windows Update (including updates from a WSUS server). The BITS protocol can be the optimal solution for transferring large ISO image and virtual machine files (VMDK, VHDX) over WAN networks.

2 comments
4
Facebook Twitter Google + Pinterest
previous post
Fix: Clock Reverts to Wrong Time After Computer (Server) Reboot
next post
Using Mandatory (Read-Only) User Profiles in Windows

Related Reading

How to Cancel Windows Update Pending Restart Loop

May 6, 2025

View Windows Update History with PowerShell (CMD)

April 30, 2025

Change BIOS from Legacy to UEFI without Reinstalling...

April 21, 2025

Remove ‘Your License isn’t Genuine’ Banner in MS...

April 21, 2025

Uninstalling Windows Updates via CMD/PowerShell

April 18, 2025

2 comments

Bud Silti October 3, 2019 - 4:22 pm

do you know how to have bits ignored self signed certs ?

Reply
George B January 22, 2021 - 3:34 pm

One item that you don’t mention, and that my Google-Fu is not strong enough to find, is does BitsTransfer verify the remote file when you’re copying ‘to’ a network/remote location?.. alongside that question, would I be correct to presume that if it did, it would effectively ‘double’ the data transfer between the source & destination?

Reply

Leave a Comment Cancel Reply

join us telegram channel https://t.me/woshub
Join WindowsHub Telegram channel to get the latest updates!

Categories

  • Active Directory
  • Group Policies
  • Exchange Server
  • Microsoft 365
  • Azure
  • Windows 11
  • Windows 10
  • Windows Server 2022
  • Windows Server 2019
  • Windows Server 2016
  • PowerShell
  • VMware
  • Hyper-V
  • Linux
  • MS Office

Recent Posts

  • Cannot Install Network Adapter Drivers on Windows Server

    April 29, 2025
  • Change BIOS from Legacy to UEFI without Reinstalling Windows

    April 21, 2025
  • How to Prefer IPv4 over IPv6 in Windows Networks

    April 9, 2025
  • Load Drivers from WinPE or Recovery CMD

    March 26, 2025
  • How to Block Common (Weak) Passwords in Active Directory

    March 25, 2025
  • Fix: The referenced assembly could not be found error (0x80073701) on Windows

    March 17, 2025
  • Exclude a Specific User or Computer from Group Policy

    March 12, 2025
  • AD Domain Join: Computer Account Re-use Blocked

    March 11, 2025
  • How to Write Logs to the Windows Event Viewer from PowerShell/CMD

    March 3, 2025
  • How to Hide (Block) a Specific Windows Update

    February 25, 2025

Follow us

  • Facebook
  • Twitter
  • Telegram
Popular Posts
  • Managing Printers and Drivers on Windows with PowerShell
  • Protecting Remote Desktop (RDP) Host from Brute Force Attacks
  • How to Set a User Thumbnail Photo in Active Directory
  • Implementing Dynamic Groups in Active Directory with PowerShell
  • Match Windows Disks to VMWare VMDK Files
  • How to View and Close Open Files on Windows Server
  • How to Get My Public IP Address with PowerShell
Footer Logo

@2014 - 2024 - Windows OS Hub. All about operating systems for sysadmins


Back To Top