A freshly provisioned Windows VPS gives you a desktop with nothing on it. The next hour is usually spent downloading installers one by one from a browser, approving UAC prompts, and hoping the vendor page you found is the real one. Chocolatey turns that hour into a single script that runs the same way on every server you build.
This article covers installing Chocolatey, building a package baseline that reflects a real Windows host, pinning versions so builds are reproducible, and running it unattended. For the hosting side, the main site covers which plans give you the disk and memory this workflow benefits from.
Why Package Management Belongs on a Windows Host
Manual installation does not scale and does not repeat. Two servers built a month apart end up with different versions of the same tool, and nobody can say which one is correct when a bug appears only on one.
| Manual install | Chocolatey baseline |
|---|---|
| Versions vary per build | Pinned versions, identical output |
| Browser plus UAC clicks | One unattended script |
| No record of what was installed | Package list in source control |
| Hours on each new box | Minutes, repeatable |
Chocolatey plays the role apt or yum play on Linux: it wraps installers, handles unattended switches, and records installed packages in a local database under C:\ProgramData\chocolatey. That record is what makes a build auditable and a future upgrade predictable.
It is not a substitute for a configuration management system. It handles packages, not file contents or registry state, and it is best used as one layer in a build pipeline rather than the whole pipeline.
Installing Chocolatey Non-Interactively
The install is a one-liner, but the surrounding choices matter. Run it from an administrator shell, allow TLS 1.2, and set the install directory and cache location before the first package lands.
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Set-ExecutionPolicy Bypass -Scope Process -Force
iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
choco --version
The script installs the shim directory at C:\ProgramData\chocolatey\bin and adds it to the machine PATH. Confirm choco --version works in a new shell before proceeding, because the PATH change does not reach an already-running session.
Configuring Sources, Proxy, and Cache
Most VPS builds pull from the community repository. If the host sits behind a proxy or a locked egress rule, configure it before the first install or every package download will fail.
choco config set proxy http://proxy.internal:8080 choco config set proxyUser svc_build choco config set proxyPassword 'REDACTED' choco config set cacheLocation D:\choco-cache choco source list
Move the cache off the system drive if the VPS has a separate data volume. Package downloads are large, and a full C: drive is the most common cause of a failed build that worked yesterday; the contact page covers storage sizing if you need a reference point.
Building a Baseline Package List
A good baseline covers the tools every server in your fleet needs, plus the runtimes specific to the workload. Group them into brackets so an IaaS web host does not get desktop-only tools it will never use.
- Core:
chocolatey-core.extension,chocolatey-compatibility.extension - Runtime:
dotnet-8.0-runtime,dotnet-6.0-windowshostingfor IIS app pools - Operations:
GoogleChromeornotepadplusplusonly on admin desktops, not servers - Diagnostics:
sysinternals,curl,7zip,git - Hosting:
iis-advanced-logging,urlrewrite,wincachewhere applicable
Keep the list in a file, not in the script, so it can be reviewed and diffed on its own. packages.config is the format Chocolatey itself uses for export and import, and it is plain enough to review in a code review with no tooling.
Every package you add increases the surface that can break a build. The default answer to “should this be in the baseline” is no, unless the workload cannot run without it.
Pinning Versions for Reproducible Builds
Unpinned packages mean the build is different every time it runs. Pin the version for anything that carries a compatibility risk, and let the rest float only after you have verified the newest release.
choco install -y --no-progress --limit-output --pin --version 8.0.403 dotnet-8.0-runtime choco pin list choco pin remove --name dotnet-8.0-runtime
Pinning is a deliberate decision, not a default. A pinned package will not receive security updates, so review pins on a schedule and remove them once the newer version has been validated. The list of pins is a list of accepted risks, and it should stay short.
Record the version numbers in the build log so you can answer “which build shipped the old runtime” a quarter later without reconstructing it from package timestamps.
The Baseline Script
The script wraps install, configuration, and verification. It should be safe to run twice: installs are idempotent, and a second run must not downgrade anything or reinstall what is already at the pinned version.
param([switch]$Upgrade)
if (-not (Get-Command choco -ErrorAction SilentlyContinue)) { throw "Chocolatey not installed" }
choco install $PSScriptRoot\packages.config -y --no-progress
if ($Upgrade) { choco upgrade all -y --except-critical }
choco list --local-only | Out-File C:\Admin\choco-installed.txt
The --except-critical flag matters when upgrading in place: it excludes packages marked as critical, such as Chocolatey itself, from a bulk upgrade that could break the build mid-run. For a fresh build, run install only; for an existing host, run with -Upgrade during a window you control.
Exit codes are the next layer of safety. Chocolatey returns 0 for success, 1641 for reboot required, and 3010 for reboot initiated. Treat those three as success in the wrapper and anything else as a build failure, with the log attached to the pipeline output.
Verification and Drift Control
A package manager is only as good as the verification around it. After the script runs, confirm the tools exist where you expect, that versions match the baseline, and that the host has not drifted since the last build.
choco list --local-only --limit-outputGet-Command git, 7z, curl | Select Name, Sourcecompare-object (Get-Content build-baseline.txt) (Get-Content choco-installed.txt)Get-Content C:\ProgramData\chocolatey\logs\chocolatey.log -Tail 50
Schedule the compare as a weekly task and alert on any difference that is not an approved upgrade. Drift is usually caused by someone installing a tool manually, which is exactly the behaviour the baseline exists to replace.
Once the script is stable, it becomes the definition of a new server: provisioning means running one script and waiting. Treat the package list as code, review changes like code, and the build stays predictable even when the person building it has changed.


