Quick Links
A lesser-known feature of Windows is the Background Intelligent Transfer Service (BITS).
Getting Started with BITS
TheBITS cmdletsare actually built-in as default PowerShell commands.
We can see what those commands are by running
.
Using the same@Paramsdeclaration, we can add a display name, in this caseTestTransfer.
By default, the BITS transfer will run at aForegroundpriority, which implies the highest transfer speed available.
This can be easily changed using one of the available priorities listed below.
As mentioned in the beginning, BITS has the unique ability to take data pipe cost into account.
To do this, we use theTransferPolicyparameter.
Since we named our transfer withTestTransferearlier on, it’s easy to find.
RunningGet-BitsTransferby itself will list all running jobs.
Suspend-BitsTransfer
With all these files transferring, sometimes there is a need to pause a transfer.
This could occur for many reasons.
This is simple with BITS, by using theSuspend-BitsTransferfunctionality.
In the example below, we are setting the job to the highest possible web connection priority.
Originally we set the job toNormal, but we need to get the job done sooner so we useForeground.
Complete-BitsTransfer
Perhaps we have suspended a job and we are ready to finish the transfer.
Using theComplete-BitsTransfercmdlet, we can tell BITS to finish all active transfer jobs.
Using-Confirm:$False, means that the jobs will be removed without a prompt for confirmation.
BITS has the ability to upload a file as well, even with authentication.
It’s important to note that the default behavior of BITS is to download multiple files automatically.
This takes standardPSCredentialobjects and works well to keep your secrets secure and encrypted within your scripts.
Conclusion
BITS is a fantastic way to control file transfers between servers and between web servers.