Copying Large Files with BITS

by May 31, 2012

You can use Copy-Item or the console applications xcopy and robocopy to copy large files. But did you know that you can also use the BITS service to do this? The BITS service is supposed to download large update files and does so in a very robust way. It can download files across multiple restarts. BITS can copy local files as well. Have a look:

Import-Module BitsTransfer

# adjust source and destination to your needs:
$Source = "C:\Images\*.ISO"
$Destination = "C:\BackupFolder\"

if ( (Test-Path $Destination) -eq $false) 
{
    $null = New-Item -Path $Destination -ItemType Directory 
}

Start-BitsTransfer -Source $Source -Destination $Destination -Description "Backup" -DisplayName "Backup" 

A couple of things to note: BitsTransfer cannot copy recursively, and it cannot copy files that are currently in use by other programs. It does display a neat progress bar, though, and it is designed to copy large files in a robust way.

Twitter This Tip! ReTweet this Tip!