BITS - PowerShell


Overview

BITS (Background Intelligent Transfer Service) manages background file transfers over HTTP/HTTPS. It optimizes transfer efficiency by resuming interrupted downloads, dividing large downloads into smaller parts, and intelligently adjusting bandwidth allocation based on network conditions.

Syntax

BITS (
  [[-Authenticate] <string>]
  [[-Credential <PSCredential>]
  [[-Destination] <string>]
  [[-Force]
  [[-Job] <string>]
  [[-MaximumConnections] <uint32>]
  [[-NoProgress]
  [[-Priority] <Priority>]
  [[-ProxyUse] <ProxyUse>]
  [[-RateLimit] <uint32>]
  [[-Remove]
  [[-Resume]
  [[-Source] <string>]
  [[-Status]
  [[-Timeout] <TimeSpan>]
  [[-TransferType] <TransferType>]
  [[-UseServerNotifications]
  [[-Verbose]
  [[-WhatIf]
)

Options/Flags

  • -Authenticate: Specify Basic or NTLM authentication.
  • -Credential: Use alternate credentials for authentication.
  • -Destination: Destination file path.
  • -Force: Overwrite existing destination file.
  • -Job: Job name (unique identifier).
  • -MaximumConnections: Set maximum concurrent connections.
  • -NoProgress: Suppress progress updates.
  • -Priority: Set download priority: High, Low, Normal (default: Normal).
  • -ProxyUse: Set proxy settings: AutoDetect, Manual:
    :, None (default: AutoDetect).
  • -RateLimit: Set maximum download speed (bits/sec).
  • -Remove: Delete the specified job.
  • -Resume: Resume an existing download.
  • -Source: Source file path or URL.
  • -Status: Display the status of the specified job.
  • -Timeout: Set job timeout (minutes).
  • -TransferType: Set transfer type: Download (default), Upload.
  • -UseServerNotifications: Enable/disable server notifications.
  • -Verbose: Display verbose output.
  • -WhatIf: Show what the command would do without executing it.

Examples

Download a file:

BITS -Source https://example.com/file.zip -Destination C:\Users\me\Downloads\file.zip

Resume a download:

BITS -Job "JobName" -Resume

Upload a file:

BITS -Source C:\Users\me\Documents\file.txt -Destination https://example.com/upload
-TransferType Upload -Credential $myCredentials

Common Issues

Error: Authentication required: Provide valid credentials with -Credential.

Slow download speed: Adjust -RateLimit or -Priority.

Incomplete download: Check network connectivity and resume the download with -Resume.

Integration

BITS can be integrated with:

  • Invoke-BitsTransfer: Transfer files using BITS in PowerShell scripts.
  • HttpWebRequest: Manage HTTP/HTTPS transfers and work with BITS in custom code.
  • Copy-Item: Copy files and folders.
  • New-WebClient: Download and upload files using a WebClient object.