Installing Pester (and Untangling v3/4 vs v5)
- PowerShell
- Pester
- Installation
- PSGallery
- Beginners
📦 Run it yourself: download the companion code pack; this part's examples are in the
01-foundations/folder (Pester 5-verified).
The most common first-day failure with Pester isn't a typo. It's that your perfectly correct Should -Be example errors out because Windows shipped Pester 3.4 years ago, and until you install a newer one, that's the version that runs your test. This part gets you to a clean Pester 5.x setup and explains exactly why this happens, so it never bites you twice.
What you'll learn
- How to check which Pester version(s) you have
- Why Windows ships an old Pester 3.4 and how it gets in the way of v5
- How to install or update Pester from the PowerShell Gallery, correctly
- How to import a specific version and verify it loaded
- The differences between Windows PowerShell 5.1 and PowerShell 7
Step 1: See what you already have
Before installing anything, look at what is on the machine:
Get-Module -ListAvailable Pester | Select-Object Name, Version, PathOn a typical Windows machine you'll often see two entries: a 3.4.0 under C:\Program Files\WindowsPowerShell\Modules (built-in), and possibly a 5.x if someone installed it. Seeing 3.4.0 is normal; Step 2 explains why it's there and where it gets in the way.
Step 2: Why the old 3.4 is there (and why it gets in the way)
Windows ships Pester 3.4 as a system module so that built-in tooling has something to rely on. The catch is that this built-in copy lives in a protected system folder, and it gets in the way when you upgrade: Update-Module refuses to touch it, and the Gallery install is blocked unless you pass -SkipPublisherCheck (both covered below). Once Pester 5 is installed, a new session loads 5.x rather than 3.4, because PowerShell picks the newest version it can find.
Why does this matter so much? Pester 5 is a near-total rewrite with different syntax. In Pester 3 you wrote Should Be 4 (space-separated). Pester 4 introduced Should -Be 4 (a real parameter), and Pester 5 accepts only the dash form. Run v5 syntax under v3 and you get confusing errors that look like your mistake but are really a version mismatch.
Step 3: Install or update from the PowerShell Gallery
Install Pester 5 from the PSGallery. These switches matter:
Install-Module Pester -MaximumVersion 5.99.99 -Force -SkipPublisherCheck -Scope CurrentUser-Forcelets the install proceed even though an older Pester (the built-in 3.4) is already present.-SkipPublisherCheckis required because the built-in 3.4 was signed by Microsoft and the Gallery release is signed differently; without this switch the install is blocked with a publisher-mismatch error.-Scope CurrentUserinstalls into your user profile, which doesn't require an elevated admin prompt.-MaximumVersion 5.99.99keeps you on Pester 5, which is what this series teaches. Since July 2026 a plainInstall-Module Pesterinstalls Pester 6, and Pester 6 changes a few behaviors covered later in the series. If you want Pester 6, the Pester 6 Edition of the Pester for Beginners book is written for it.
On a machine that has never installed anything from the PowerShell Gallery, Windows PowerShell first stops with NuGet provider is required to continue and asks whether to install it, ending in [Y] Yes [N] No [S] Suspend [?] Help (default is "Y"). Answer Y. It's a one-time download that Install-Module needs, and the Pester install carries on as soon as it finishes. The download can take a few minutes; let it run.
If you prefer a system-wide install, drop -Scope CurrentUser and run from an elevated session.
Step 4: Import a specific version and verify
Do not trust a bare import. Ask for v5 explicitly:
# Force any old copy out of this session first, then import 5.x
Remove-Module Pester -ErrorAction SilentlyContinue
Import-Module Pester -MinimumVersion 5.0 -MaximumVersion 5.99.99
Get-Module Pester | Select-Object Name, VersionThat last line should report a Version of 5.x (for example, 5.9.1). If the import fails with no valid module file was found and the last line prints nothing, Pester 5 isn't installed yet: go back to Step 3. The -MaximumVersion matters if Pester 6 is also installed: without it, PowerShell picks the newest version it can find. You can also pin an exact build with -RequiredVersion and the version you just saw (for example, -RequiredVersion 5.9.1) when you need reproducibility.
Step 5: PowerShell 5.1 vs PowerShell 7
Two PowerShells exist, and Pester works on both:
- Windows PowerShell 5.1 is the one preinstalled on Windows. This is where the built-in 3.4 lives, so the steps above matter most here.
- PowerShell 7 (the cross-platform, open-source edition) doesn't ship its own Pester, but on Windows it can still find and load the built-in 3.4 from the Windows PowerShell module folder, so run the same install and import steps above.
For learning, either is fine.
Try it yourself
Your goal: reach a clean Get-Module Pester showing 5.x loaded.
# 1. What do you have?
Get-Module -ListAvailable Pester | Select-Object Version, Path
# 2. Install the modern release
Install-Module Pester -MaximumVersion 5.99.99 -Force -SkipPublisherCheck -Scope CurrentUser
# 3. Load 5.x explicitly in a fresh session
Remove-Module Pester -ErrorAction SilentlyContinue
Import-Module Pester -MinimumVersion 5.0 -MaximumVersion 5.99.99
# 4. Prove it
Get-Module Pester | Select-Object Name, VersionIf you already installed Pester 5 earlier in this session, step 2 warns that the version is currently in use and leaves it alone. That's fine: the version you need is already installed.
When step 4 prints a 5.x version, you are ready for the rest of the series. Tuck this snippet away, you will run it on every new machine.
Common mistakes
Expecting
Update-Module Pesterto get you to Pester 5. Windows put the built-in 3.4 there, notInstall-Module, soUpdate-Modulerefuses to touch it and stops with an error:Module 'Pester' was not installed by using Install-Module, so it cannot be updated.UseInstall-Module ... -MaximumVersion 5.99.99 -Force -SkipPublisherCheckinstead, which installs a fresh 5.x alongside it. Once that 5.x is in place, a plainUpdate-Module Pesterwould move you to Pester 6, so keep the cap there too:Update-Module Pester -MaximumVersion 5.99.99.Forgetting
-SkipPublisherCheck. Without it, the install fails with a publisher-mismatch error because the old built-in copy is signed differently from the Gallery release. This is the single most common install blocker.Mixing v3 and v5 syntax in one session. If an old Pester is loaded, v5 examples like
Should -Befail in baffling ways. AlwaysRemove-Module Pesterand re-import with-MinimumVersion 5.0 -MaximumVersion 5.99.99when in doubt, then checkGet-Module Pester.
Recap
Windows ships Pester 3.4 in a protected path, and because Windows put it there rather than Install-Module, Update-Module refuses to update it. Install from the PSGallery with -MaximumVersion 5.99.99 -Force -SkipPublisherCheck, then import explicitly with -MinimumVersion 5.0 -MaximumVersion 5.99.99 and verify with Get-Module Pester. PowerShell 7 doesn't ship Pester, but on Windows it can still load the built-in 3.4, so the same steps apply.
Next up: Part 3, Your First Test: Describe, It, and Should, where you finally write a real (and very small) Pester test, watch it pass, then break it on purpose to see it turn red.
Posts here are written with AI assistance and tested against real code before publishing.