powershellscripts.com

Tutorials  PowerShell Cmdlet Help for Add-BitsFile



NAME
Add-BitsFile

SYNOPSIS
Adds one or more files to an existing Background Intelligent Transfer Service (BITS) transfer job.

SYNTAX
Add-BitsFile [-BitsJob] [-Source] [[-Destination] ] [-Confirm] [-WhatIf] [ arameters>]


DESCRIPTION
The Add-BitsFile cmdlet adds files to a BITS transfer job. You can specify the files to add to the BITS transfer jo
b by name at the command prompt or in a comma-separated value (CSV) file.

Important: An upload job can contain only one file. To upload more than one file, use the Import-CSV cmdlet, and pi
pe the output to the Add-BitsFile cmdlet. For more information, see example 3 in this Help topic. Or, use a cabinet
file (.cab) or a compressed file (.zip).


PARAMETERS
-BitsJob
Specifies the BITS transfer jobs to which you want to add files. You can pipe a value to this parameter from ot
her cmdlets that return BitsJob objects, such as Get-BitsTransfer.

Required? true
Position? 1
Default value
Accept pipeline input? true (ByValue)
Accept wildcard characters? false

-Destination
Specifies the destination location and the names of the files that you want to transfer. The destination names
are paired with the corresponding source file names. For example, the first file name specified in the Source p
arameter corresponds to the first file name in the Destination parameter, and the second file name in the Sourc
e parameter corresponds to the second file name in the Destination parameter. The Source and Destination parame
ters must have the same number of elements; otherwise, the command produces an error.

Required? false
Position? 3
Default value
Accept pipeline input? true (ByPropertyName)
Accept wildcard characters? false

-Source
Specifies the source location and the names of the files that you want to transfer. The source file names are p
aired with the corresponding destination file names. For example, the first file name specified in the Source p
arameter corresponds to the first file name in the Destination parameter, and the second file name in the Sourc
e parameter corresponds to the second file name in the Destination parameter. The Source and Destination parame
ters must have the same number of elements; otherwise, the command produces an error. You can use standard wild
card characters such as the asterisk (*) and the question mark (?), or you can use a range operator such as "[a
-r]".

Required? true
Position? 2
Default value
Accept pipeline input? true (ByPropertyName)
Accept wildcard characters? true

-Confirm []
Prompts you for confirmation before executing the command.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-WhatIf []
Describes what would happen if you executed the command without actually executing the command.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false


This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

INPUTS
Microsoft.BackgroundIntelligentTransfer.Management.BitsJob[]
This cmdlet accepts one or more BitsJob objects as input that populates the BitsJob parameter.


OUTPUTS
Microsoft.BackgroundIntelligentTransfer.Management.BitsJob[]
This cmdlet generates the BitsJob objects that are associated with the BITS transfer jobs to which the files we
re added.


NOTES





-------------------------- EXAMPLE 1 --------------------------

C:\PS>Get-BitsTransfer -JobId 10778CFA-C1D7-4A82-8A9D-80B19224879C | Add-BitsFile -Source http://server01/servertes
tdir/testfile1.txt -Destination c:\clienttestdir\testfile1.txt


Description
-----------
This command appends a file to the transfer queue of an existing BITS transfer job.

In this example, the output of the Get-BitsTransfer cmdlet is a BitsJob object that is identified by its unique job
ID. The command pipes the job ID to the Add-BitsFile cmdlet. The local and remote names of the file are in the par
ameters.





-------------------------- EXAMPLE 2 --------------------------

C:\PS>$b = Get-BitsTransfer -JobId 10778CFA-C1D7-4A82-8A9D-80B19224879C
Add-BitsFile -BitsJob $b -Source http://server01/servertestdir/testfile1.txt, http://server01/servertestdir/testfil
e2.txt -Destination c:\clienttestdir\testfile1.txt, c:\clienttestdir\testfile2.txt


Description
-----------
This command appends a set of files to the transfer queue of an existing BITS transfer job.

The first command retrieves the BITS transfer job that is identified by the job ID and then stores it in the $b var
iable. The second command uses the BitsJob parameter to pass the BitsJob object that is stored in the $b variable t
o Add-BitsFile.

The server file names are paired with the corresponding client file names.





-------------------------- EXAMPLE 3 --------------------------

C:\PS>$b = Start-BitsTransfer -Suspended
Import-CSV filelist.txt | Add-BitsFile -BitsJob $b
Resume-BitsTransfer -BitsJob $b


Description
-----------
These commands add a set of files to the transfer queue of a new BITS transfer job.

The first command creates a new BitsJob object and then stores it in the $b variable.

The second command uses the Import-CSV cmdlet to import a text file that contains a list of files to be transferred
. The text file is converted to an array of objects (one per line) and passed through the pipeline to the Add-BitsF
ile cmdlet. The BitsJob parameter is used to pass the BitsJob object (the transfer job) that is stored in the $b va
riable to the Add-BitsFile cmdlet. This command also updates the transfer job with the list of files to be transfer
red.

The third command passes the BitsJob object that is stored in the $b variable to the Resume-BitsTransfer cmdlet. Th
e BITS transfer job is restarted, and the files that are specified in the Filelist.txt file are transferred from th
e source to the destination.


The "Import-CSV filelist.txt" element of the second command imports a text file that contains the list of files to
be transferred. Each line of this file specifies a file to be transferred, in the , format. Th
e text file is converted to an array of objects (one per line) and passed through the pipeline. In this example, th
e array of objects is passed to the Add-BitsFile cmdlet.

The contents of the Filelist.txt file resemble the following information:


Source, Destination
http://server01/servertestdir/testfile1.txt, c:\clienttestdir\testfile1.txt
http://server01/servertestdir/testfile2.txt, c:\clienttestdir\testfile2.txt
http://server01/servertestdir/testfile3.txt, c:\clienttestdir\testfile3.txt
http://server01/servertestdir/testfile4.txt, c:\clienttestdir\testfile4.txt






RELATED LINKS
Online version: http://go.microsoft.com/fwlink/?LinkId=141425
Complete-BitsTransfer
Get-BitsTransfer
Remove-BitsTransfer
Resume-BitsTransfer
Set-BitsTransfer
Start-BitsTransfer
Suspend-BitsTransfer