install-kubectl.ps1


<#PSScriptInfo
 
.VERSION 1.0
 
.GUID 32a11a36-f91c-4241-a11f-af0cf3e90f38
 
.AUTHOR Karsten.Bott@labbuildr.com
 
.COMPANYNAME
 
.COPYRIGHT
 
.TAGS
 
.LICENSEURI
 
.PROJECTURI
 
.ICONURI
 
.EXTERNALMODULEDEPENDENCIES
 
.REQUIREDSCRIPTS
 
.EXTERNALSCRIPTDEPENDENCIES
 
.RELEASENOTES
 
 
#>


<#
 
.DESCRIPTION
 This script is used during unsattended installs or to download kubectl on windows
 
#>
 
param(
$Downloadlocation = $env:TEMP
)

if (!(Test-Path $Downloadlocation))
    {
    New-Item -ItemType Directory $Downloadlocation
    } 
$uri = "https://kubernetes.io/docs/tasks/tools/install-kubectl/"
$req = Invoke-WebRequest -UseBasicParsing -Uri $uri
try
    {
    $downloadlink = ($req.Links | where href -Match "kubectl.exe").href
    }
catch
    {
    Write-Warning "Error Parsing Link"
    }
Start-BitsTransfer $downloadlink -DisplayName "Getting KubeCTL" -Destination $Downloadlocation