Bootstrap FreeKB - PowerShell - Download and install a file
PowerShell - Download and install a file

Updated:   |  PowerShell articles

Here is an example PowerShell script that should download kubectl.exe to C:\Temp\kubectl.exe. 

$webclient = New-Object System.Net.WebClient
$url = "https://dl.k8s.io/release/v1.28.3/bin/windows/amd64/kubectl.exe"
$dest = "C:\Temp\kubectl.exe"

try {
    $webclient.DownloadFile($src, $dest)
} catch {
    Write-Warning "caught the following error"
    foreach ($line in $Error) {
      Write-Warning $line
    }
    return    
}

Write-Host "Successfully downloaded $url to $file"

 

And then the following could be used to install the kubectl.exe.

try {
    start C:\Temp\kubectl.exe /verysilent
} catch {
    Write-Warning "caught the following error"
    foreach ($line in $Error) {
      Write-Warning $line
    }
    return    
}

Write-Host "Successfully installed kubectl"

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 26f6c5 in the box below so that we can be sure you are a human.