Install instructions#
Prerequisites#
- Windows PowerShell 5.1 with .NET Framework 4.7.2+ or
- PowerShell 7.2 or greater on Windows, MacOS, and Linux
For a list of platforms that PowerShell 7.2 is supported on see.
Getting the module#
Install from PowerShell Gallery for all users (requires permissions):
# Install PSRule module
Install-Module -Name 'PSRule' -Repository PSGallery;
Install from PowerShell Gallery for current user only:
# Install PSRule module
Install-Module -Name 'PSRule' -Repository PSGallery -Scope CurrentUser;
Save for offline use from PowerShell Gallery:
# Save PSRule module, in the .\modules directory
Save-Module -Name 'PSRule' -Repository PSGallery -Path '.\modules';
For pre-release versions the
-AllowPrerelease
switch must be added when callingInstall-Module
orSave-Module
.To install pre-release module versions, upgrading to the latest version of PowerShellGet may be required. To do this use:
Install-Module -Name PowerShellGet -Repository PSGallery -Scope CurrentUser -Force
Getting the extension for Visual Studio Code#
Install the latest release from the Visual Studio Marketplace.
Within Visual Studio Code (VSCode) search for PSRule
in the extensions pane.
Install by the command line:
code --install-extension bewhite.psrule-vscode-preview
NOTE: If you are using the Insiders build, the command will be
code-insiders
.
For detailed instructions, follow the steps in the Visual Studio Code documentation.
Getting the extension for Azure Pipelines#
Install the latest release from the Visual Studio Marketplace. For detailed instructions see Install extensions.
If you don't have permissions to install extensions within your Azure DevOps organization, you can request it to be installed by an admin instead.
Getting the GitHub action#
Add the latest version from the GitHub Marketplace to a workflow.
- name: Run PSRule analysis
uses: Microsoft/ps-rule@v1.10.0
For detailed instructions and change log see the action details.
Building from source#
To build this module from source run ./build.ps1
.
This build script will compile the module and documentation then output the result into out/modules/PSRule
.
The following PowerShell modules will be automatically downloaded if the required versions are not present:
- PlatyPS
- Pester
- PSScriptAnalyzer
- PowerShellGet
- PackageManagement
- InvokeBuild
These additional modules are only required for building PSRule and are not required for running PSRule.
If you are on a network that does not permit Internet access to the PowerShell Gallery, download these modules on an alternative device that has access. The following script can be used to download the required modules to an alternative device. After downloading the modules copy the module directories to devices with restricted Internet access.
# Save modules, in the .\modules directory
Save-Module -Name PlatyPS, Pester, PSScriptAnalyzer, PowerShellGet, PackageManagement, InvokeBuild -Repository PSGallery -Path '.\modules';
Additionally .NET Core SDK v3.1 is required. .NET Core will not be automatically downloaded and installed. To download and install the latest SDK see Download .NET Core 3.1.