Site icon TOSS

Start-BitsTransfer

powershell

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

Synopsis

Creates a BITS transfer job.

Description

The Start-BitsTransfer cmdlet creates a Background Intelligent Transfer Service (BITS) transfer job to transfer one or more files between a client computer and a server. The TransferType parameter specifies the direction of the transfer. By default, after the cmdlet begins the transfer, the command prompt is not available until the transfer is complete or until the transfer enters an error state. If the state of the returned BitsJob object is Error, the error code and description are contained in the object and can be used for analysis.

The Start-BitsTransfer cmdlet supports the download of multiple files from a server to a client computer, but it does not generally support the upload of multiple files from a client computer to a server. If you need to upload more than one file, you can use the Import-Csv cmdlet to pipe the output to the Add-BitsFile cmdlet to upload multiple files. Or, if you need to upload more than one file, consider a cabinet file (.cab) or a compressed file (.zip).

Parameters

-Asynchronous

Indicates that the cmdlet creates and processes BITS transfer job in the background. The command prompt reappears immediately after the BITS transfer job is created. The returned BitsJob object can be used to monitor status and progress.

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

-Authentication

Specifies the authentication mechanism to be used at the server. The acceptable values for this parameter are:

Type:String
Accepted values:Basic, Digest, Ntlm, Negotiate, Passport
Position:Named
Default value:None
Accept pipeline input:False
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

-Credential

Specifies the credentials to use to authenticate the user to the server that is specified in the value of the Source parameter. The default is the current user.

Type a user name, such as “User01”, “Domain01\User01”, or “User@TOSSolution.com”. Or, use the Get-Credential cmdlet to create the value for this parameter. When you type a user name, you are prompted for a password.

Type:PSCredential
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-Description

Describes the BITS transfer job. The description is limited to 1,024 characters.

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-Destination

Specifies an array that contains 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 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:1
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False

-DisplayName

Specifies a display name for the BITS transfer job. The display name provides a user-friendly way to differentiate BITS transfer jobs.

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-Priority

Sets the priority of the BITS transfer job, which affects bandwidth usage. The acceptable values for this parameter are:

Type:String
Accepted values:Foreground, High, Normal, Low
Position:Named
Default value:Foreground
Accept pipeline input:False
Accept wildcard characters:False

-ProxyAuthentication

Specifies the authentication mechanism to use at the Web proxy. The acceptable values for this parameter are:

Type:String
Accepted values:Basic, Digest, Ntlm, Negotiate, Passport
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-ProxyBypass

Specifies a list of host names to use for a direct connection. The hosts in the list are tried in order until a successful connection is achieved. If you specify this parameter the cmdlet bypasses the proxy. If this parameter is used, the ProxyUsage parameter must be set to Override; otherwise, an error occurs.

Type:String[]
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-ProxyCredential

Specifies the credentials to use to authenticate the user at the proxy. You can use the Get-Credential cmdlet to create a value for this parameter.

Type:PSCredential
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-ProxyList

Specifies a list of proxies to use. The proxies in the list are tried in order until a successful connection is achieved. If this parameter is specified and ProxyUsage is set to a value other than Override, the cmdlet generates an error.

Type:Uri[]
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-ProxyUsage

Specifies the proxy usage settings. The acceptable values for this parameter are:

Type:String
Accepted values:SystemDefault, NoProxy, AutoDetect, Override
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-RetryInterval

Specifies the minimum length of time, in seconds, that BITS waits before an attempt to transfer the file after BITS encounters a transient error. The minimum allowed value is 60 seconds. If this value exceeds the RetryTimeout value from the BitsJob object, BITS does not retry the transfer. Instead, BITS sets the state of the BITS transfer job to the Error state.

The default is 600 seconds (10 minutes).

Type:Int32
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-RetryTimeout

Specifies the length of time, in seconds, that BITS attempts to transfer the file after the first transient error occurs. Setting the retry period to 0 prevents retries and forces the job into the BG_JOB_STATE_ERROR state when an error occurs. If the retry period value exceeds the JobInactivityTimeout Group Policy setting (90-day default), BITS cancels the job after the JobInactivityTimeout Group Policy setting is exceeded.

The default is 1,209,600 seconds (14 days).

Type:Int32
Position:Named
Default value:None
Accept pipeline input:False
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 example, 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:0
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False

-Suspended

Indicates that the cmdlet suspends the BITS transfer job. If the Suspended parameter is not specified, the job automatically begins the transfer job. If the Suspended parameter is specified, the command prompt returns immediately after the BITS transfer job is created. You can use the Resume-BitsTransfer cmdlet to start the transfer job.

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

-TransferPolicy

Specifies the network cost states in which the transfer is allowed to be scheduled. The current cost state of the network is a bitmask that indicates the kinds of charges that would be incurred if a transfer was scheduled at this time. This cost state represents a bitmask; if the bit corresponding to the current network cost state is set, the transfer can be scheduled. If the bit corresponding to the current network cost state is not set, the transfer is ignored for scheduling purposes. You can submit any of the named values listed here, or add them together to provide a custom value.

The acceptable values for this parameter are:

The cost state also includes one option (IgnoreCongestion) and a set of standard policies (Always, NotRoaming, NoSurcharge, Standard, and Uncosted) which are combinations of the discrete bit values.

Type:CostStates
Accepted values:None, Unrestricted, Capped, BelowCap, NearCap, OverCapCharged, OverCapThrottled, UsageBased, Roaming, IgnoreCongestion, PolicyUnrestricted, Standard, NoSurcharge, NotRoaming, Always
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-TransferType

Specifies the BITS transfer job type. The acceptable values for this parameter are:

Type:String
Accepted values:Download, Upload, UploadReply
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-UseStoredCredential

Specifies that credentials stored in the Windows Credential Manager should be used for authentication when required for the specified target server type. If this parameter is not specified and a server requires authentication, then explicit credentials must be included by using the Credential or ProxyCredential parameters. This parameter is a flag parameter whose values can be added together to create the desired behavior.

The acceptable values for this parameter are:

Type:AuthenticationTargetValue
Accepted values:None, Server, Proxy
Position:Named
Default value:None
Accept pipeline input:False
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

Start-BitsTransfer [-Asynchronous] [-Authentication <String>] [-Credential <PSCredential>] [-Description <String>] [[-Destination] <String[]>] [-DisplayName <String>] [-Priority <String>] [-TransferPolicy <CostStates>] [-UseStoredCredential <AuthenticationTargetValue>] [-ProxyAuthentication <String>] [-ProxyBypass <String[]>] [-ProxyCredential <PSCredential>] [-ProxyList <Uri[]>] [-ProxyUsage <String>] [-RetryInterval <Int32>] [-RetryTimeout <Int32>] [-Source] <String[]> [-Suspended] [-TransferType <String>] [-WhatIf] [-Confirm] [<CommonParameters>]

Notes
You can cancel a transfer job that is running in synchronous mode by pressing CTRL+C.

——————-Example 1——————-
Create a BITS transfer job that downloads a file
PS C:>Start-BitsTransfer -Source “http://FTPServer01/transfer/transferfile1.txt” -Destination “c:\client\transferfile1.txt”
This command creates a BITS transfer job that downloads a file from a server. The local and remote names of the file are specified in the Source and Destination parameters. Because the default transfer type is Download, the http://FTPServer01/transfer/transferfile1.txt file is transferred to C:\client\transferfile1.txt on the client. The command prompt returns when the file transfer is complete or when it enters an error state.
When you upload files to an HTTP location, the TransferType parameter must be set to Upload.
Because the Start-BitsTransfer cmdlet assumes that the first parameter is the source and that the second parameter is the destination when no value is specified, this command could be simplified as follows:
Start-BitsTransfer “http://FTPServer01/transfer/transferfile1.txt” “c:\client\transferfile1.txt”

——————-Example 2——————-
Create BITS transfer jobs that download multiple files
PS C:>Import-CSV filelist.txt | Start-BitsTransfer
This command creates BITS transfer jobs that download multiple files from a server.
The command imports the source and destination file locations and then pipes the locations to the Start-BitsTransfer command. The Start-BitsTransfer command creates a new BITS transfer job for each of the files in filelist.txt and then transfers them concurrently to the client.
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

——————-Example 3——————-
Create a BITS transfer job that uploads a file
PS C:>Start-BitsTransfer -Source “c:\client\transferfile1.txt” -Destination “http://FTPServer01/transfer/transferfile1.txt” -TransferType Upload
This command creates a BITS transfer job that uploads a file to a server. The local and remote names of the file are specified in the Source and Destination parameters. Because the default transfer type is Download, the TransferType parameter must be set to Upload. The C:\client\transferfile1.txt file on the client is transferred to http://FTPServer01/transfer/transferfile1.txt. The command prompt returns when the file transfer is complete or enters an error state.
The Start-BitsTransfer cmdlet downloads multiple files from a server to a client computer, but it does not typically upload multiple files from a client computer to a server. It is possible to work around this limitation by using the Import-Csv cmdlet to pipe the output to the Start-BitsTransfer cmdlet. If you need to upload more than one file, you can also use a .cab or .zip file.
Because the Start-BitsTransfer cmdlet assumes that the first parameter is the source and that the second parameter is the destination when no value is specified, this command could be simplified as follows:
Start-BitsTransfer “c:\client\transferfile1.txt” “http://FTPServer01/transfer/transferfile1.txt” -TransferType Upload

——————-Example 4——————-
Create a BITS transfer job that downloads multiple files
PS C:>Start-BitsTransfer -Source “http://FTPServer01/transfer/transferfile1.txt”, “http://FTPServer01/transfer/transferfile2.txt” -Destination “c:\client\transferfile1.txt”, “c:\client\transferfile2.txt”
This command creates a BITS transfer job that downloads multiple files from a server.
The local and remote names of the files are specified in the Source and Destination parameters. Because the default of the TransferType parameter is Download, the http://FTPServer01/transfer/transferfile1.txt and http://FTPServer01/transfer/transferfile2.txt files are transferred to C:\client\transferfile1.txt and C:\client\transferfile2.txt on the client computer. The command prompt returns when the file transfer is complete or enters an error state.

——————-Example 5——————-
Create a BITS transfer job that downloads a file using a specific set of credentials
PS C:>$Cred = Get-Credential
PS C:> Start-BitsTransfer -DisplayName MyJob -Credential $Cred -Source “http://FTPServer01/transfer/transferfile1.txt” -Destination “c:\client\transferfile1.txt”
This example creates a BITS transfer job that downloads a file from a server by using a specific set of credentials.
The first command retrieves a set of credentials from the user by calling the Get-Credential cmdlet. The returned PSCredential object is stored in the $Cred variable.
The second command uses the Credential parameter to pass the PSCredential object that is stored in the $Cred variable to the Start-BitsTransfer cmdlet. A new BITS transfer job is created that downloads the http://FTPServer01/transfer/transferfile1.txt file to the client. The specified credentials are used to authenticate the user at the server. Additionally, the optional DisplayName parameter is used to give the BITS transfer job a unique name.

——————-Example 6——————-
Create BITS transfer jobs that download multiple files
PS C:>Import-CSV filelist.txt | Start-BitsTransfer -Asynchronous -Priority Normal
This command creates BITS transfer jobs that download multiple files from a server. The files are downloaded sequentially, but they are available immediately when the transfer job is complete.
The command imports the source and destination file locations and then pipes them to the Start-BitsTransfer command. The Start-BitsTransfer command creates a new BITS transfer job for each of the files in filelist.txt and then transfers them sequentially to the client
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

——————-Example 7——————-
Create a BITS transfer job that downloads multiple files
PS C:>Start-BitsTransfer -Source “http://FTPServer01/transfer/*.” -Destination “c:\client\”
This command creates a BITS transfer job that downloads multiple files from a server.
The Start-BitsTransfer command creates a new BITS transfer job. All the files are added to a single job and then transferred sequentially to the client.
The following command shows another variation of a file transfer command that uses a wildcard character:
Start-BitsTransfer -Source “http://FTPServer01/transfer/*.txt” -Destination “c:\client\”
The destination path cannot use wildcard characters. The destination path supports only a relative directory, a rooted path, or an implicit directory (the current directory). Additionally, the destination files cannot be renamed by using a wildcard character. For instance, the following command does not work:
c:\client*.BAK

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

Get-Command Start-BitsTransfer

You can also read about

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

Exit mobile version