UPDATE: BITS PowerShell cmdlets has gone through some changes between Win7 beta and Win7 RC. This posting has been updated accordingly.
The BITS (Background Intelligent Transfer Service) team is happy to announce the release of BITS PowerShell cmdlets in Windows 7! BITS PowerShell cmdlets combine the richness and usability of PowerShell scripting with the network-awareness and persistence of BITS file transfers. We believe that the addition of BITS cmdlets will make it easier for admins to manage and automate file transfer tasks by providing the following benefits.
For PowerShell admins considering BITS:
· Politeness: File transfers can be conducted in the background to preserve the responsiveness of other network apps
· Fire-and-forget persistence: BITS automatically tries to resume transfers that have been interrupted by temporary hiccups such as network disconnections or system reboots
For BITS API and BITSAdmin considering the switch to PowerShell cmdlets:
· Admin-Focused: Automate file transfers tasks in an extensible and management-oriented scripting language
· Usability: Consistent syntax across PowerShell cmdlets makes PowerShell scripting easy to learn and use
A primer on BITS can be found at http://msdn.microsoft.com/en-us/library/aa362708(VS.85).aspx.
On your mark…
Before using the BITS cmdlets, they must be loaded using the following cmdlet.
Import-Module FileTransfer Import-Module BitsTransfer
This cmdlet needs to be called whenever a new PowerShell session is started. This step can be avoided by adding the above cmdlet to your profile script. The location of this script is given by the $profile variable. Once this has been added to the profile script, the BITS cmdlets are loaded whenever a new PowerShell session is started.
Discovering and navigating through all of the BITS PowerShell cmdlets can be a daunting task. A good place to start is by running the following cmdlet, which lists all of the BITS PowerShell cmdlets.
Get-Command –Module FileTransfer Get-Command -Module BitsTransfer
Without further ado, here are the BITS cmdlets in a nutshell… or PowerShell.
Start Your Engines
Creates a BITS job to transfer one or more files between two locations. By default, this cmdlet operates in synchronous mode and returns when all files have been transferred. A file transfer done in this mode is similar to a simple copy command. Managing file transfer tasks is not supported in this mode since it blocks until all files have been transferred.
This cmdlet can also operate in asynchronous mode, where it returns a BITS job object immediately. Think of this mode as the starting point for managing file transfers tasks. In general, a BITS job should be created asynchronously before passing it as a parameter to the other BITS cmdlets .
(Note: It is possible to modify synchronously created BITS jobs from a different PowerShell session using BITS cmdlets or from a CMD prompt using the BITSAdmin tool. This is not recommended, since it is much simpler to just modify BITS jobs created using the asynchronous mode.)
Meet Your Pit Crew
Adds one or more files to a BITS job.
Retrieves a list of BITS jobs for the current user. This cmdlet is handy for piping a list of BITS jobs into another cmdlet. For example, you can pipe this into the Remove-BitsTransfer cmdlet to cancel all BITS jobs.
Modifies the properties of a BITS job. This is handy for changing BITS job properties on the fly, such as changing the aggressiveness of a BITS job.
Suspends a BITS job. This cmdlet pauses a BITS job’s file transfers until the BITS job is resumed by the Resume-BitsTransfer cmdlet.
Resumes a BITS job. Calling this cmdlet will resume a suspended BITS job and start file transfers from where they left off.
Completes and removes a BITS job. Using this cmdlet will save any transferred files and remove the BITS job.
Cancels and removes a BITS job. This is similar to Complete-BitsTransfer with one exception. Files that are part of the BITS job will not be saved, even if they have been transferred.
Give the BITS cmdlets a test drive and explore how they can be used to satisfy your file transfer needs. Keep reading in the future for some examples and ideas on using BITS cmdlets!
Lost, Need Directions?
For examples and documentation on how to use each cmdlet, try looking at the cmdlet help.
Get-Help <Cmdlet Name>
For more information about BITS, check out the following link:
Alex Ng [MSFT]