aboutsummaryrefslogtreecommitdiffstats
path: root/coin/provisioning/common/helpers.ps1
diff options
context:
space:
mode:
Diffstat (limited to 'coin/provisioning/common/helpers.ps1')
-rw-r--r--coin/provisioning/common/helpers.ps120
1 files changed, 20 insertions, 0 deletions
diff --git a/coin/provisioning/common/helpers.ps1 b/coin/provisioning/common/helpers.ps1
index d7b957f3..055ce0a7 100644
--- a/coin/provisioning/common/helpers.ps1
+++ b/coin/provisioning/common/helpers.ps1
@@ -29,3 +29,23 @@ function Extract-Zip
$destinationFolder = $shell.Namespace($Destination)
$destinationFolder.CopyHere($zipfile.Items(), 16)
}
+
+function BadParam
+{
+ Param ([string]$Description)
+ throw("You must specify $Description")
+}
+
+function Download
+{
+ Param (
+ [string] $OfficialUrl = $(BadParam("the official download URL")),
+ [string] $CachedUrl = $(BadParam("the locally cached URL")),
+ [string] $Destination = $(BadParam("a download target location"))
+ )
+ try {
+ Invoke-WebRequest -UseBasicParsing $CachedUrl -OutFile $Destination
+ } catch {
+ Invoke-WebRequest -UseBasicParsing $OfficialUrl -OutFile $Destination
+ }
+}