From 2ab5ac1d3db3c5d217bae188b36e9879390addaf Mon Sep 17 00:00:00 2001 From: Sam Erde <20478745+SamErde@users.noreply.github.com> Date: Thu, 1 Feb 2024 12:46:43 -0500 Subject: [PATCH] Playing with BITS --- Get-BITSDownload.ps1 | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Get-BITSDownload.ps1 diff --git a/Get-BITSDownload.ps1 b/Get-BITSDownload.ps1 new file mode 100644 index 0000000..b362374 --- /dev/null +++ b/Get-BITSDownload.ps1 @@ -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)" +}