Background Intelligent Transfer Service (BITS) transfers files (downloads or uploads) between a client and server and provides progress information related to the transfers. You can also download files from a peer.  BITS can transfer files asynchronously between a client and a server.  VMM uses BITS to transfer payload between managed computers.  These data transfers are encrypted by using a self-signed certificate generated at the time a host machine is added to VMM.

 

Verify BITS outside of VMM

 

The following steps can be used to verify that BITS is working properly outside of VMM.

To verify BITS:

  1. Download BITSadmin.exe using the above link. It is also in the Windows Server 2003 Resource Kit.  It does not appear in the tools directory, but is accessible from the command line.
  2. Click on … Start > Programs > Windows Resource Kit Tools > Command Shell
  3. This should open an elevated command prompt
  4. Create a C:\Temp directory if one does not already exist
  5. Type the following command:  bitsadmin /transfer myDownloadJob /download /priority normal http://msdl.microsoft.com/download/symbols/debuggers/dbg_amd64_6.11.1.404.msi c:\temp\dbg_amd64_6.11.1.404.msi
  6. This command will automatically use BITSadmin.exe to test BITS functionality by downloading a file from our website to the local temp directory
  7. This should take 10-20 minutes to complete
  8. This test should be ran on the VMM management server, Host computer and Source machine

 

BITS Compact Server

 

This method will allow you to test BITS in the same manner in which VMM uses BITS.
On the destination host, try the following steps: 

  1. Disable BITS Compact Server.  This feature is found in the Add/Remove Feature wizard.
  2. Restart computer
  3. Re-enable BITS Compact Server

If you tried these steps and still have problems, run the following command on the host machine:

winrm invoke CreateJob wmi/root/microsoft/bits/BitsClientJob @{Displayname="Test of fake job";RemoteUrl="http://download.microsoft.com/download/D/0/E/D0E6D2C1-2593-4017-B26D-7375BC9263D5/PowerShell_Setup_amd64.msi";LocalFile="PATH_TO_LOCAL_DESTINATION";Type="0";ServiceAccount="0";Suspend="true";Description="Description for fake job"}

Replace PATH_TO_LOCAL_DESTINATION with a path to an existing directory, but to a non-existing file (e.g., c:\httpRec\test.txt, where directory c:\httpRec exists, but test.txt in that directory does not). Don't provide path to an existing file, as it might overwrite it. This will attempt to create a BITS client job to download a file from a fake url.
Take note of the output.
If job succeeds, record the JobId.
Example:
CreateJob_OUTPUT

    JobId = {8DC2BE2F-0D2A-41B8-AEAD-F6DBED586E98}

    ReturnValue = 0
If above command succeeds, clean up the job by the following command:

winrm Invoke SetJobState wmi/root/microsoft/Bits/BitsClientJob?JobID={8DC2BE2F-0D2A-41B8-AEAD-F6DBED586E98} @{JobState="0"}

Replacing jobID with the job ID for your job. If the JobId was not returned with the CreateJob command above, you can find created dummy job by:

bitsadmin /list /allusers

Look for job with above name/description. 

Also look for any Suspended jobs and delete by using the following commands:

   Bitsadmin /cancel {Job_GUID}

BITS Traces 

Occasionally it will be necessary to obtain BITS traces while reproducing the error.

Create bitslog.cmd using below batch file

Open an elevated powershell and navigate to the "C:\bits folder"
Type the following commands:
     Bitslog /enable
     Bitslog /collect c:\bits                     # choose an appropriate directory name
Perform operations and reproduce failure
Type the following commands from powershell
     Bitslog /disable
Collect the bits.log file for analysis

The following batch file should be renamed bitslog.cmd

@echo off

REM Script for enabling bits logging/collection to be used

REM while reporting BITS issues

 

setlocal ENABLEDELAYEDEXPANSION

 

set DEFAULT_LOG_SIZE=20

set DEFAULT_LOG_DIR=%TEMP%\bits-logs

set BitsKey=HKLM\Software\Microsoft\Windows\CurrentVersion\BITS

 

if {%1} == {} goto Usage

 

if {%1} == {/enable} goto :EnableLog

if {%1} == {/e} goto :EnableLog

 

if {%1} == {/disable} goto :DisableLog

if {%1} == {/d} goto :DisableLog

 

if {%1} == {/collect} goto :CollectLog

if {%1} == {/c} goto :CollectLog

 

goto :Usage

 

:EnableLog

if {%2} == {} (

set log_size=%DEFAULT_LOG_SIZE%

) else (

set log_size=%2

)

echo Enabling logging for BITS with log file size as %log_size%

reg add %BitsKey% /v LogFileFlags /t REG_DWORD /d 0xfbcf /f > NUL

reg add %BitsKey% /v LogFileSize /t REG_DWORD /d %log_size% /f > NUL

 

echo Restarting BITS for registry values to take effect

net stop bits

net start bits

goto :eof

 

 

:DisableLog

echo Disabling logging for BITS

reg delete %BitsKey% /v LogFileFlags /f > NUL

reg add %BitsKey% /v LogFileSize /f > NUL

 

echo Restarting BITS for registry values to take effect

net stop bits

net start bits

goto :eof

 

 

:CollectLog

if {%2} == {} (

set log_dir=%DEFAULT_LOG_DIR%

) else (

set log_dir=%2

)

if NOT EXIST %log_dir% (

md %log_dir% > NUL

if ERRORLEVEL 1 (

echo Failed to create the log dir %log_dir%. Not saving logs

goto :eof

)

)

echo Copying the BITS logs to %log_dir% directory

REM Flush the current log for BITS

logman update bits -ets -fd > NUL

copy %windir%\system32\bits.log %log_dir% /y

copy %windir%\system32\bits.bak %log_dir% /y

 

REM copy the build info

reg query "HKLM\Software\Microsoft\Windows NT\CurrentVersion" /v BuildLab >

%log_dir%\bld_info

 

REM get the output of bitsadmin

bitsadmin /list /allusers /verbose > %log_dir%\AllJobs.txt

goto :eof

 

 

:Usage

echo BITSLOG usage

echo bitslog /enable [^<no^>] - To enable BITS logging and specify the log size as ^<no^> MB

echo BITS service will be restarted

echo If ^<no^> is not specified, default is 20 MB

echo bitslog /disable - To disable BITS logging

echo BITS service will be restarted

echo bitslog /collect [^<dir^>] - To collect BITS logs in the specified dir

echo If ^<dir^> is not specified, default is %%TEMP%%\bits-logs

goto :eof

Useful KB Articles and Blogs

More VMM Troubleshooting topics:

System Center 2012 – Virtual Machine Manager (VMM) General Troubleshooting Guide