Add-BitsFile

Add-BitsFile is accessible with the help of BitsTransfer module. To configure BitsTransfer, go through this link.

Synopsis

Adds one or more files to an existing BITS transfer job.

Description

The Add-BitsFile cmdlet adds files to a Background Intelligent Transfer Service (BITS) transfer job. You can specify the files to add to the BITS transfer job 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 pipe 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 other cmdlets that return BitsJob objects, such as Get-BitsTransfer.

Type:BitsJob[]
Position:0
Default value:None
Accept pipeline input:True (ByValue)
Accept wildcard characters:False

-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:False
Accept pipeline input:False
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 instance, the first file name specified in the Source parameter corresponds to the first file name in the Destination parameter, and the second file name in the Source parameter corresponds to the second file name in the Destination parameter. The Source and Destination parameters must have the same number of elements; otherwise, the command produces an error.

Type:String[]
Position:2
Default value:None
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 paired with the corresponding destination file names. For instance, the first file name specified in the Source parameter corresponds to the first file name in the Destination parameter, and the second file name in the Source parameter corresponds to the second file name in the Destination parameter. The Source and Destination parameters must have the same number of elements; otherwise, the command produces an error. You can use standard wildcard characters such as the asterisk (*) and the question mark (?), or you can use a range operator such as “[a-r]”.

Type:String[]
Position:1
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:False
Accept pipeline input:False
Accept wildcard characters:False

Syntax

Add-BitsFile [-BitsJob] <BitsJob[]> [[-Destination] <String[]>] [-Source] <String[]> [-WhatIf] [-Confirm] [<CommonParameters>]

—————Example 1—————
Append a file to the transfer queue of an existing BITS transfer job
PS C:>Get-BitsTransfer -JobId <JobID> | Add-BitsFile -Source http://FTPServer01/transfer/transferfile.txt -Destination “c:\client\transferfile.txt”
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 parameters.

—————Example 2—————
Append a set of files to the transfer queue of an existing BITS transfer job
PS C:>$Bits = Get-BitsTransfer -JobId <JobID>
PS C:> Add-BitsFile -BitsJob $Bits -Source “http://FTPServer01/transfer/transferfile1.txt”, “http://FTPServer01/transfer/transferfile2.txt” -Destination “c:\client\transferfile1.txt”, “c:\client\transferfile2.txt”
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 variable. The second command uses the BitsJob parameter to pass the BitsJob object that is stored in the $b variable to Add-BitsFile.
The server file names are paired with the corresponding client file names.

—————Example 3—————
Add a set of files to the transfer queue of a new BITS transfer job
PS C:>$Bits = Start-BitsTransfer -Suspended
PS C:> Import-CSV filelist.txt | Add-BitsFile -BitsJob $Bits
PS C:> Resume-BitsTransfer -BitsJob $Bits
This example adds 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 $Bits 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-BitsFile cmdlet. The BitsJob parameter is used to pass the BitsJob object (the transfer job) that is stored in the $Bits variable to the Add-BitsFile cmdlet. This command also updates the transfer job with the list of files to be transferred.
The third command passes the BitsJob object that is stored in the $Bits variable to the Resume-BitsTransfer cmdlet. The BITS transfer job is restarted, and the files that are specified in the Filelist.txt file are transferred from the 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. The text file is converted to an array of objects, one per line, and passed through the pipeline. In this example, the array of objects is passed to the Add-BitsFile cmdlet.
The contents of the Filelist.txt file resemble the following information:
Source, Destination
http://FTPServer01/transfer/transferfile1.txt, c:\client\transferfile1.txt
http://FTPServer01/transfer/transferfile2.txt, c:\client\transferfile2.txt
http://FTPServer01/transfer/transferfile3.txt, c:\client\transferfile3.txt
http://FTPServer01/transfer/transferfile4.txt, c:\client\transferfile4.txt

You can check the Version, CommandType and Source of this cmdlet by giving below command.

Get-Command Add-BitsFile

Get-Command Add-BitsFile powershell sctip command cmdlet

You can also read about

  • Complete-BitsTransfer
  • Get-BitsTransfer
  • Remove-BitsTransfer
  • Resume-BitsTransfer
  • Set-BitsTransfer
  • Start-BitsTransfer
  • Suspend-BitsTransfer

To know more PowerShell cmdlets(Commands) on BitsTransfer click here

Click on this Link for an Single place where you get all the PowerShell cmdlet sorted based on the modules.

You can also refer other blogs on PowerShell at link

You can also refer other blogs on Microsoft at link

And also if you required any technology you want to learn, let us know below we will publish them in our site http://tossolution.com/

Like our page in Facebook and follow us for New technical information.

References are taken from Microsoft

Leave a Reply

Your email address will not be published. Required fields are marked *