Friday 22 May 2020

Background Intelligent Transfer Service


Quick About

The BIT Service is a way to download files or upload to and form an HTTP or SMB file server, BITS is a background process that will continue to download files even after the application that triggered it has closed as long as the user remains logged in to the system.

The service has 4 state-changing methods, Suspend, Resume, Cancel, or Complete

The Suspend method is used to switch a job to the SUSPENDED state. When a job is suspended, all of its transfers will be stopped and won't resume until you call Resume. A job that's already suspended will simply stay suspended

The Resume method is used to start a job that's suspended. Jobs in an error or transient error state will be set up to be retried. Jobs that are currently in an action state will stay in that state.

The Cancel method is used to cancel a job. The state will switch to cancelled. Any files currently being transferred will not be completed. All completely transferred and partially transferred files will be deleted.

The Complete method will finish a transfer. Any fully downloaded files will be kept; files that are not fully transferred will be deleted.

You must call either Cancel or Complete to move your job to a final state and be cleaned up. Jobs that aren't transitioned to a final state will waste system resources. BITS will eventually automatically cancel old jobs.

The default JobInactivityTimeout is to cancel jobs after 90 days.

For more details on states please see White paper on BITS Life Cycle​
https://docs.microsoft.com/en-us/windows/win32/bits/life-cycle-of-a-bits-job

Troubleshooting

To see what is going in within BITS, open PowerShell and type the following

Import-Module BITSTransfer

This will load the BITSTransfer and give you the following commands

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

Get-BitsTransfer -AllUsers
This command will return all jobs on the server and the current state its in

Get-BitsTransfer -Allusers | Select *
This command will show you more information on each job and the file list of what its downloading.

Get-BitsTransfer -Allusers | Select -ExpandProperty FileList | Out-File C:\\\\\\\\Filelist.txt
This will output a text file that lists all the files form all the jobs and where and too they are getting downloaded too

If you are seeing an error state in BITS this command should output which file is playing up.

If you are dealing with a long list you can short cut it by

Get-BitsTransfer -AllUsers | foreach {get-bitstransfer -jobid $_.jobid | select -ExpandProperty FileList | where {$_.BytesTransferred -eq 0} | select -first 1}
​Which will just list all the problem downloads only

No comments:

Post a Comment