Pester is compatible with every version of Windows that can run at least PowerShell 3. That includes: Windows 10, 8, 7, Vista, and their respective Server versions 2016, 2012 R2, 2012, 2008 R2 and 2008.
Windows 10 and Windows Server 2016 make installing and updating PowerShell modules extremely simple by providing
Unfortunately there are some complications specific to Pester that we cannot avoid.
Pester version 3.4.0 ships as part of Windows 10 and Windows server 2016, and that distribution conflicts with the standard module update mechanism.
It is not possible to update the built-in Pester to a newer version, using the
Instead you need to perform a new side-by-side installation of Pester, because
Install-Module detects the current installation of Pester is signed with a different signature than the one you are installing.
Here's the command you need to run as administrator in order to get the latest version of Pester:
-SkipPublisherCheck option is typically required for machines that only have v3.4.0 installed as mentioned above.
That particular version of the module was signed by Microsoft to be shipped in-box, which is not the case for later versions which are community maintained and signed with a different certificate.
Attempting to install the module without that option may fail.
If you receive the following warning when trying to install the module, you may need to explicitly enable TLS 1.2:
To enable TLS 1.2 for the current PowerShell instance, you can run the following code, and then re-run the installation command:
If you need to remove the built-in version of Pester on your machine, you can do so by executing the following code:
For any subsequent update it is enough to run:
The way you can install a new module differs based on the version of PowerShell you are using. Determine the version of PowerShell you are using by running:
In version 5 or newer you can use the built-in
Update-Module cmdlets coming from PowerShellGet.
From an administrative PowerShell command line run:
Or to update:
On PowerShell 3 and 4, there is no default package manager installed, but luckily PowerShellGet is available for installation. See detailed instructions here. When you have the package manager installed, please start a new administrator PowerShell window and use:
Or to update:
To install Pester you don't have to use any package manager. Downloading and installating it manually can be useful in e.g. offline envionments.
- Download the module on a machine with internet using either:
Save-Module -Name Pester -Path C:\Temp. It will save it in a versioned folder, ex C:\Temp\Pester\5.0.4
- Or download the NuGet package from PowerShell Gallery, see Manual Package Download
- Copy the Pester-folder (ex. C:\Temp\Pester) to your destination computer and place it in one of your module directories defined by $env:PSModulePath. On a Windows-system it will by default include:
- C:\Program Files\WindowsPowerShell\Modules
- Start PowerShell and start testing.
Step 2 is optional if you don't need simple import, automatic module detection or module auto-loading. If so, you need to import the module using an absolute path like
PSGallery is the easiest way to get Pester installed to your computer, but there are alternatives. On a build server you might prefer using Chocolatey, or if you're adding Pester to your .NET project that already uses NuGet, you might prefer using NuGet. These options may not support pre-release versions and it may need to be initialized on first use. For those reasons you might prefer installing from the other available sources.
Chocolatey (or choco) is the easiest way to get Pester running on AppVeyor. You avoid setting up PowerShellGet and it also supports pre-release versions.
Or to update:
You can also pass the
--prerelease option to install or update to a prerelease version of Pester instead.
Nuget is the package manager for .NET projects. Getting Pester from Nuget is useful when you are integrating PowerShell code with your .NET project, and want to have that code tested. To install use Package Manager of Visual Studio, or Package Manager Console in Visual Studio. Once you need this we are pretty sure you know what you are doing. 🙂