Download the latest Hashicorp Terraform, Packer, and Vault bits

I created a PowerShell Script that downloads the latest version of Terraform, Packer, and Vault, extracts the archives to binaries, and adds the folder of the path environment variable. Running this script ensures you always work with the latest versions of Terraform, Packer, and Vault.

    .DESCRIPTION Function to download and extract the latest Packer, Terraform and Vault version from Hashicorp
    .NOTES Author:  Ivo Beerens
    .NOTES Site:
    .NOTES Version: 1.0
    .NOTES Changed: September 10, 2023 
    .NOTES Reason:  Creation

#Enable TLS 1.2
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
#Speed up the Invoke-Webrequest command
$ProgressPreference = 'SilentlyContinue'

$temp_folder = "c:\install\" #Temp download location 
$hashicorp_destination = "c:\install\hashicorp\" #Path for storing the Hashicorp binaries

#Check if the temp folder exists
If(!(test-path -PathType container $hashicorp_destination )) {
    New-Item -ItemType Directory -Path $hashicorp_destination 

#Jump to the download folder
Set-Location $hashicorp_destination 

Function Download-Hashicorp {
    param (
     try {
        Write-Host "............ Download $product from Hashicorp ............" -ForegroundColor Green
        $urls = Invoke-WebRequest -Uri $url| Select-Object -Expand links | Where-Object href -match "//releases\.hashicorp\.com/$product/\d.*/$product_.*_windows_amd64\.zip$" | Select-Object -Expand href
        $filename = $urls | Split-Path -Leaf
        $download = $temp_folder + $filename
        #Download Hashicorp bits
        Invoke-WebRequest $urls -outfile $download
        #Expand archive
        Write-Host "............ Expand $product archive to binary ............" -ForegroundColor Yellow
        Expand-Archive $download -DestinationPath $hashicorp_destination -Force
        Write-Host "............ Remove $product archive download............" -ForegroundColor Blue
        #Remove download
        Remove-Item $download
     catch {
        Write-Host "An error occurred while downloading or extracting $product" -ForegroundColor Red
        throw $_.Exception.Message

#Download Packer, Vault, and Terraform 
$products = @{
    'packer' = ''
    'vault' = ''
    'terraform' = ''

foreach ($product in $products.GetEnumerator()) {
    Download-Hashicorp -product $product.Name -url $product.Value

##Add the Hashicorp binary folder to the system environment variable path
Write-Host "............ Add folder to path ............" -ForegroundColor Green
[Environment]::SetEnvironmentVariable("PATH", $Env:PATH + ";" + $hashicorp_destination, [EnvironmentVariableTarget]::User)
Write-Host "Please restart your PowerShell session for the changes to take effect." -ForegroundColor Yellow

Line 15: Change the temp folder for storing the downloaded archive files
Line 16: Change the folder path for storing the Hashicorp binaries for Terraform, Packer, and Vault
Line 19-22: Check if the folder for storing the Hashicorp binaries for Terraform, Packer, and Vault exists. If not it will be created
Line 24-50: Function that downloads and extracts the archive files for Terraform, Packer, and Vault
Line 52-61: Run the function to download and extract the Hashicorp Terraform, Packer, and Vault
Line 63-66: adds the folder of the Hashicorp binaries to the path environment variable

The latest version of this script can be found on my GitHub page, Link.


The latest technology news week 26–2023

Here’s the latest weekly technology news from Microsoft, including updates on Microsoft Azure, Microsoft Azure Virtual Desktop (AVD), Windows 365, VMware, and HashiCorp Terraform.

Microsoft Azure

  • June 2023 update. Link
  • Azure Landing Zones Public Roadmap. Link
  • Azure AD Security Config Analyzer (AADSCA). Link
  • How to reset multi-factor authentication (MFA). Link
  • Announcing Trusted Launch as default in Azure Portal. Link
  • Using Resource Locks To Prevent Accidental Changes In Azure. Link

Microsoft AVD

  • Session hosts are not available in Azure Virtual Desktop, but VMs are running. Link
  • Test Azure Virtual Desktop on-prem? Link
  • Want To Accelerate Azure Virtual Desktop? Link
  • STOP Copying Files in AVD! DO This Instead. Link
  • Microsoft VDI Bill of Materials – AVD/Citrix on Azure/VMware Horizon on Azure. Link
  • Move on-premises Remote Desktop Services to Azure Virtual Desktop scenario. Link
  • It is not supported to roam the OneDrive registry hive as part of a non-persistent VDI environment. Link

Windows 365

  • Application Deployment in Windows 365 – Recommended Practices. Link


  • Azure access from GitHub and GitLab pipelines – without secrets. Link
  • The Awesome Azure DevOps repository contains a list of Azure DevOps content created by Microsoft and the community! Link


  • Terraform Best Practices: The 20 Practices You Should Adopt. Link


  • Evaluation Guide for VMware Horizon 8. Link
  • Lessons Learned with UAG Deployments for Workspace ONE. Link


  • PowerShell Client-Checker security script. Link
  • How to Send Emails Using Microsoft Graph PowerShell. Link

Quick tip: Reset the password of an Azure Virtual Machine

In my Azure test tenant, I forgot the password of an Azure Windows Domain Controller VM. In Azure, there is a Reset Password option available in the VM options.


The password reset update failed. The password reset option uses a VM Access extension. When digging into the activity log I found the following error:

VMAccess Extension does not support Domain Controller

So I went to another approach using the following steps:


  • Ensure the VM status is running
  • Create a new password
    • Portal – between 12 – 123 characters
    • PowerShell – between 8 – 123 characters
    • CLI – between 12 – 123
    • Have lower characters
    • Have upper characters
    • Have a digit
    • Have a special character (Regex match [\W_])

Using the Azure portal

    • Log in to the Azure portal
    • Navigate to the Virtual Machine that you want to reset the password for.
    • Select the Virtual Machine
    • Select Run Command
    • Select RunPowerShellScript
    • In the “Run Command Script” window enter:
net user <username> <password>


Using Cloud Shell

  • Log in to the Azure portal
  • In the Azure Portal open Cloud Shell
  • Select Bash
  • In the following command change: <vm> <resource group the vm belongs > <username> and <password>
az vm run-command invoke --command-id RunPowerShellScript --name <vm> -g <resource group the VM belongs too> --scripts "net user <username> <password>"



Using the RunPowerShellScript is a lifesaver when you forgot the password of a Windows Domain Controller VM in Azure. This procedure works also for regular Windows VMs.