Skip to content

Instantly share code, notes, and snippets.

@rodmhgl
Created February 10, 2022 23:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rodmhgl/2d4b036bc4c959db29a29c371af0bada to your computer and use it in GitHub Desktop.
Save rodmhgl/2d4b036bc4c959db29a29c371af0bada to your computer and use it in GitHub Desktop.
Downloads and installs Terraform. $tfPath will be added to PATH permanently via registry settings - run as Administrator.
$pathKey = 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment'
$tfFilename = 'terraform_1.1.5_windows_amd64.zip'
$tfURL = "https://releases.hashicorp.com/terraform/1.1.5/$tfFilename"
$tfPath = 'C:\tf'
Invoke-WebRequest $tfURL -UseBasicParsing -OutFile $tfFilename
Expand-Archive ".\$tfFilename" -DestinationPath $tfPath -Force
$oldpath = (Get-ItemProperty -Path $pathKey -Name PATH).path
$newpath = "$oldpath;$tfPath;"
Set-ItemProperty -Path $pathKey -Name PATH -Value $newpath -whatif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment