diff options
Diffstat (limited to 'coin/provisioning/common/helpers.ps1')
-rw-r--r-- | coin/provisioning/common/helpers.ps1 | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/coin/provisioning/common/helpers.ps1 b/coin/provisioning/common/helpers.ps1 index d7b957f3..0e684452 100644 --- a/coin/provisioning/common/helpers.ps1 +++ b/coin/provisioning/common/helpers.ps1 @@ -29,3 +29,32 @@ 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 + } +} + +function Add-Path +{ + Param ( + [string]$Path + ) + echo "Adding $Path to Path" + [Environment]::SetEnvironmentVariable("Path", $env:Path + ";$Path", [EnvironmentVariableTarget]::Machine) +} |