How Can We Help?
How to reset the 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 were definitely an issue with BITS and for some reason it had failed to download a bunch of jobs and many where queued up.
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 therefore 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.