Skip to main content

Scripted installation of Chef Habitat on Windows

·246 words·2 mins

I spotted this week that we have made a subtle change to the Chef Habitat installation instructions on Windows and added a new scripted install option via PowerShell.

In general, we recommend using Chocolatey to install the latest version of Chef Habitat on your Windows-based workstations. If you have Chocolatey installed, this can be as simple as running:

choco install habitat -y

If you have a CI system (such as Azure Pipelines or Jenkins) or just want to stay on the bleeding edge rather than the stable builds pushed to Chocolatey, then you might want a more direct route to installing the latest version and we now provide a PowerShell script that can be used to install and configure specific versions of Habitat.

Assuming you have a modern (Windows 10, Windows Server 2016 or higher) Windows installation then installation can now be as short as running the following PowerShell command:

iex "& { $(irm <https://raw.githubusercontent.com/habitat-sh/habitat/master/components/hab/install.ps1)> }"

If you need to specify the version you can use the following example:

iex "& { $(irm <https://raw.githubusercontent.com/habitat-sh/habitat/master/components/hab/install.ps1)> } -Version 0.75.0"

If you are using Azure Pipelines, you can simply include this PowerShell step in your azure-pipelines.yml file:

trigger:
- master

pool:
  vmImage: 'windows-2019'

steps:
- task: PowerShell@2
  inputs:
    targetType: 'inline'
    script: 'iex "& { $(irm <https://raw.githubusercontent.com/habitat-sh/habitat/master/components/hab/install.ps1)> }"'

When running the job in your pipeline, you should see output as follows:

mvp-renewal

Azure Pipelines showing a PowerShell step installing Habitat on a build agent.

Source: official Habitat installation docs for Windows