Example 1
1 |
C:\PS>Start-BitsTransfer -Source https://server01/servertestdir/testfile1.txt -Destination c:\clienttestdir\testfile1.txt |
Description
———–
This command creates a new 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 https://Server01/servertestdir/testfile1.txt file is transferred to C:\clienttestdir\testfile1.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 https://server01/servertestdir/testfile1.txt c:\clienttestdir\testfile1.txt
Example 2
1 |
C:\PS>Import-CSV filelist.txt | Start-BitsTransfer |
Description
———–
This command creates a new BITS transfer job that downloads 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, adds the files to a single job, and then transfers them sequentially to the client.
The contents of the Filelist.txt file resemble the following information:
Source, Destination
https://server01/servertestdir/testfile1.txt, c:\clienttestdir\testfile1.txt
https://server01/servertestdir/testfile2.txt, c:\clienttestdir\testfile2.txt
https://server01/servertestdir/testfile3.txt, c:\clienttestdir\testfile3.txt
https://server01/servertestdir/testfile4.txt, c:\clienttestdir\testfile4.txt
Example 3
1 |
C:\PS>Start-BitsTransfer -Source c:\clienttestdir\testfile1.txt -Destination |
https://server01/servertestdir/testfile1.txt -TransferType Upload
Description
———–
This command creates a new 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:\clienttestdir\testfile1.txt file on the client is transferred to https://Server01/servertestdir/testfile1.txt. The command prompt returns when the file transfer is complete or enters an error state.
Important: The Start-BitsTransfer cmdlet lets you download multiple files from a server to a client computer, but it does not typically let you 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:\clienttestdir\testfile1.txt https://server01/servertestdir/testfile1.txt -TransferType Upload
Example 4
1 |
C:\PS>Start-BitsTransfer -Source https://server01/servertestdir/testfile1.txt, https://server01/servertestdir/testfile1.txt -Destination c:\clienttestdir\testfile1.txt, c:\clienttestdir\testfile1.txt |
Description
———–
This command creates a new 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 https://Server01/servertestdir/testfile1.txt and https://Server01/servertestdir/testfile2.txt files are transferred to C:\clienttestdir\testfile1.txt and C:\clienttestdir\testfile2.txt on the client computer. The command prompt returns when the file transfer is complete or enters an error state.
Example 5
1 2 |
C:\PS>$c = Get-Credential New-FileTransfer -DisplayName MyJob -Credential c$ -Source https://server01/servertestdir/testfile1.txt -Destination c:\clienttestdir\testfile1.txt |
Description
———–
These commands create a new 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 $c variable.
The second command uses the Credential parameter to pass the PSCredential object that is stored in the $c variable to the Start-BitsTransfer cmdlet. A new BITS transfer job is created that downloads the https://server01/servertestdir/testfile1.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
1 |
C:\PS>Import-CSV filelist.txt | Start-BitsTransfer -Asynchronous -Priority Normal |
Description
———–
This command creates a new BITS transfer job that downloads multiple files from a server. The files will be downloaded sequentially, but they will be 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, adds the files to a single job, and then transfers them sequentially to the client.
The contents of the Filelist.txt file resemble the following information:
Source, Destination
https://server01/servertestdir/testfile1.txt, c:\clienttestdir\testfile1.txt
https://server01/servertestdir/testfile2.txt, c:\clienttestdir\testfile2.txt
https://server01/servertestdir/testfile3.txt, c:\clienttestdir\testfile3.txt
https://server01/servertestdir/testfile4.txt, c:\clienttestdir\testfile4.txt
Example 7
1 |
C:\PS>Start-BitsTransfer -Source https://server01/servertestdir/*.* -Destination c:\clienttestdir\ |
Description
———–
This command creates a new 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 https://server01/servertestdir/*.txt -Destination c:\clienttestdir\
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 example, the following command does not work:
c:\clienttestdir\*.BAK
Example 8
1 |
C:\PS>Import-CSV filelist.txt | Start-BitsTransfer -TransferType Upload |
Description
———–
This command creates a new BITS transfer job that uploads multiple files from a client.
The command imports the source and destination file locations and then pipes them to to the Start-BitsTransfer command. The Start-BitsTransfer command creates a new BITS transfer job, adds the files to a single job, and then transfers them sequentially to the client.
The contents of the Filelist.txt file resemble the following information:
Source, Destination
c:\clienttestdir\testfile1.txt, https://server01/servertestdir/testfile1.txt
c:\clienttestdir\testfile2.txt, https://server01/servertestdir/testfile2.txt
c:\clienttestdir\testfile3.txt, https://server01/servertestdir/testfile3.txt
c:\clienttestdir\testfile4.txt, https://server01/servertestdir/testfile4.txt