Installation
Prerequisites
Before installing py-psscriptanalyzer, ensure you have the following:
Python
py-psscriptanalyzer requires Python 3.9 or later:
python --version # Should be 3.9 or higher
PowerShell
PowerShell Core (pwsh) must be installed and available in your system PATH.
Windows
Option 1: Microsoft Store (Recommended)
# Install from Microsoft Store using winget
winget install --id Microsoft.PowerShell --source winget
Option 2: Direct Download
Download from the PowerShell GitHub releases page.
macOS
# Using Homebrew (recommended)
brew install powershell
# Or using MacPorts
sudo port install powershell
Linux
Ubuntu/Debian
# Update package index
sudo apt update
# Install dependencies
sudo apt install -y wget apt-transport-https software-properties-common
# Download Microsoft signing key and repository
wget -q "https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb"
sudo dpkg -i packages-microsoft-prod.deb
# Update package index after adding Microsoft repository
sudo apt update
# Install PowerShell
sudo apt install -y powershell
CentOS/RHEL/Fedora
# Register Microsoft signature key
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
# Register Microsoft repository
curl https://packages.microsoft.com/config/rhel/8/prod.repo | sudo tee /etc/yum.repos.d/microsoft.repo
# Install PowerShell
sudo dnf install -y powershell
Verify PowerShell Installation
pwsh --version
Install py-psscriptanalyzer
From PyPI (Recommended)
pip install py-psscriptanalyzer
From Source
# Clone the repository
git clone https://github.com/thetestlabs/py-psscriptanalyzer.git
cd py-psscriptanalyzer
# Install using pip
pip install .
Verify Installation
py-psscriptanalyzer --version
py-psscriptanalyzer --help
Development Installation
For contributors and developers:
# Clone the repository
git clone https://github.com/thetestlabs/py-psscriptanalyzer.git
cd py-psscriptanalyzer
# Install uv (modern Python package manager)
pip install uv
# Install dependencies and development tools
uv sync --group dev --group docs
# Install in editable mode
uv pip install -e .
# Install pre-commit hooks
uv run pre-commit install
Troubleshooting
PowerShell Not Found
If you encounter “PowerShell not found” errors:
Verify PowerShell is installed:
which pwsh # On Unix-like systems where pwsh # On Windows
Test PowerShell directly:
pwsh -Command "Write-Output 'Hello World'"
Check your PATH: Ensure the PowerShell installation directory is in your system PATH.
PSScriptAnalyzer Module Missing
py-psscriptanalyzer automatically installs the PSScriptAnalyzer PowerShell module on first use. If installation fails:
Install manually:
pwsh -Command "Install-Module -Name PSScriptAnalyzer -Force -Scope CurrentUser"
Verify installation:
pwsh -Command "Get-Module -ListAvailable PSScriptAnalyzer"
Permission Issues
On Unix-like systems, you may need to adjust the PowerShell execution policy:
pwsh -Command "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser"
Python Version Issues
Ensure you’re using Python 3.9 or later:
python --version
pip --version
If you have multiple Python versions, you may need to use python3 and pip3 instead.
Next Steps
After installation:
See Usage for command-line usage examples
See Configuration for pre-commit hook setup and advanced configuration
See Development for contributing guidelines