install-kubectl.ps1


<#PSScriptInfo
 
.VERSION 1.1
 
.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 -ErrorAction SilentlyContinue | out-null
    } 
$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
$Downloadfile = Join-Path $Downloadlocation "kubectl.exe"
Unblock-File $Downloadfile
Write-Host "You can now start kubectl from $Downloadfile"