Skip to content

Commit

Permalink
Playing with BITS
Browse files Browse the repository at this point in the history
  • Loading branch information
SamErde committed Feb 1, 2024
1 parent d09e7af commit 2ab5ac1
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions Get-BITSDownload.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<#
.SYNOPSIS
Quickly download a file using BITS.
.DESCRIPTION
BITS can be used to speed up transfers, used as an alternative to Invoke-WebRequest,
or used to provide resiliency when a download is interrupted.
#>

function Get-BITSDownload {
[CmdletBinding()]
param (

)

$url = "http://files.net/test/file1.test"
$output = "$PSScriptRoot\file1.test"
$start_time = Get-Date

Import-Module BitsTransfer

Start-BitsTransfer -Source $url -Destination $output
# OR
Start-BitsTransfer -Source $url -Destination $output -Asynchronous

Write-Output "Time taken: $((Get-Date).Subtract($start_time).Seconds) second(s)"
}

0 comments on commit 2ab5ac1

Please sign in to comment.