PowerShell for Windows Admins

Mar 4 2012   2:45PM GMT

Upload through BITS



Posted by: Richard Siddaway
BITS

Downloading through BITS is easy as we have seen,  Uploading requites some work. First the BITS IIS extensions have to be loaded.  Restart IIS and look at the properties of the Virtual Directory being used for the transfer.  At the bottom you should find a BITS upload option in the Other section.  Double click and enable uploads.  Configure other properties as desired.

A single file upload can be achieved like this

Start-BitsTransfer -Source c:\source\transfer\testupload.txt -Destination http://webr201/transfer/testupload.txt -TransferType Upload

For multiple file uploads try this

Import-Module BitsTransfer -Force            
            
$computername = "WebR201"            
$source = "c:\source\transfer\"            
            
Get-ChildItem -Path $source |            
foreach {            
             
$destination =  "http://webr201/transfer/$($_.name)"            
Write-Host "Transferring $($_.Fullname) to $destination"            
            
Start-BitsTransfer -Source $($_.Fullname) -Destination $destination -TransferType Upload            
            
}

Import the module. Set the machine name & source folder. Run Get-ChildItem over the folder and for each file set up a BITS transfer source and destination variables using the name and fullname. Run the transfer.

Comment on this Post

Leave a comment: