- C:
- Program Files
- WindowsPowerShell\Modules
FolderRisk: Caution
WindowsPowerShell\Modules C:\Program Files\WindowsPowerShell\Modules
PowerShell modules installed for all users (Install-Module -Scope AllUsers); the recommended location for your own Windows PowerShell modules.
What it’s for
PowerShell modules installed for every user of the machine. Install-Module -Scope AllUsers puts the module here, and it is the recommended place to copy your own company modules: the path is in $env:PSModulePath for Windows PowerShell and for PowerShell 7, without touching Windows folders.
What it contains
- One folder per module and, inside it, one folder per version (
<Module>\<Version>\<Module>.psd1), so several versions can sit side by side. - Modules installed from the PowerShell Gallery or an internal repository, or copied by hand.
- Per-user modules (
-Scope CurrentUser) are not here: they go toDocuments\WindowsPowerShell\Modules.
Risks and best practices
- A module from this folder runs with the rights of whoever imports it: on a server, restrict write access to administrators, which is the default, and sign internal modules.
- On a server without Internet access, download the module on a connected machine with
Save-Module, then copy the folder here, keeping the version folder structure. - Keep track of what is installed (
Get-InstalledModule): an update can bring in a version that breaks a script, so pin the version with-RequiredVersion.
Useful commands
# Modules installed by PowerShellGetGet-InstalledModule
# Modules present in this folderGet-Module -ListAvailable | Where-Object Path -like 'C:\Program Files\WindowsPowerShell\Modules*' | Select-Object Name, Version
# Prepare a module for an offline serverSave-Module -Name Pester -Path C:\Temp\Modules
# Uninstall all versions of a module (as administrator)Uninstall-Module -Name Pester -AllVersions -WhatIf