MSEndpointMgr

How to reset BITS transfer queue

While troubleshooting a client that intermittently was reporting Waiting for content back to ConfigMgr, I found that the BITS transfer queue had gone total bananas. In this scenario I was pushing a firewall configuration to a number of clients for testing before the big roll out. At first I thought that there were some boundary issues, but that was not the issue. While looking at the execmgr.log file, I could definitely see that the client was waiting for the content to be downloaded.
Since this was a server running Windows Server 2012, I had access to the really great PowerShell cmdlet called:

Get-BitsTransfer

With this excellent cmdlet, it’s really easy to see all the BITS transfers that are currently in progress. Now, the ConfigMgr client is running as the Local System account. Therefor in order to see BITS transfers from the ConfigMgr client we have to run the following command:

Get-BitsTransfer -AllUsers

When I executed this command, it became clear to me why the client was reporting Waiting for content. As you can see in the picture below, there where definitely an issue with BITS and for some reason it had failed to download a bunch of jobs and many where queued up.
87_1
Since BITS uses a round robin like method to try and resume those transfers that had a temporary error (transient error), I didn’t want to wait for that complete. Instead I decided to reset the BITS transfer queue on the client in this case. You can do this by either going at it a single job at a time, or actually remove the whole queue completely. You could of course use PowerShell to only remove the jobs that are in a failed state, if you want to go with that method, this one-liner should be enough:

Get-BitsTransfer -AllUsers | Where-Object { $_.JobState -like "TransientError" } | Remove-BitsTransfer

But as I said, I needed to see if the firewall configuration was working, and therefor I decided to remove the whole queue completely. This can be accomplished by running a batch script. Why a batch script? Well, it will work on systems where the Get-BitsTransfer cmdlet is not available. Here’s the batch file that I created:

@echo off
net stop BITS
ipconfig /flushdns
ren "%ALLUSERSPROFILE%\Application Data\Microsoft\Network\Downloader\qmgr0.dat" qmgr0.dat.old
ren "%ALLUSERSPROFILE%\Application Data\Microsoft\Network\Downloader\qmgr1.dat" qmgr1.dat.old
net start BITS

I saved the above batch script to a .bat file and ran it from an elevated command prompt. I then checked the BITS transfer queue again by running:

Get-BitsTransfer -AllUsers

The BITS transfer queue was now empty. After that I re-deployed the firewall configuration package to the client and it was now downloaded successfully by BITS.

Nickolaj Andersen

Chief Technical Architect and Enterprise Mobility MVP since 2016. Nickolaj has been in the IT industry for the past 10 years specializing in Enterprise Mobility and Security, Windows devices and deployments including automation. Awarded as PowerShell Hero in 2015 by the community for his script and tools contributions. Creator of ConfigMgr Prerequisites Tool, ConfigMgr OSD FrontEnd, ConfigMgr WebService to name a few. Frequent speaker at conferences such as Microsoft Ignite, NIC Conference and IT/Dev Connections including nordic user groups.

8 comments

Sponsors

Categories

MSEndpointMgr.com use cookies to ensure that we give you the best experience on our website.