Home › Blog › Powershell

Powershell

Managing PowerShell Modules in Windows: How to Install, Update, and Remove Them

PowerShell modules are collections of cmdlets for managing Windows components, server roles, cloud services, and other systems. You can install them from the PowerShell Gallery or other repositories, then update or remove them as needed.

Manage PowerShell repositories

List the repositories registered on a computer:

Get-PSRepository

To add a repository hosted in a shared network folder:

Register-PSRepository -Name myCORPPSRepo `  -SourceLocation \mun-man01PSRepo `  -InstallationPolicy Trusted

Remove a repository with:

Unregister-PSRepository myCORPPSRepo

The PowerShell Gallery is not trusted by default, so PowerShell may prompt you before installing a module from it. To mark it as trusted:

Set-PSRepository -Name PSGallery -InstallationPolicy Trusted

If the default gallery was removed, restore it with:

Register-PSRepository -Default

Install modules from a repository

Search registered repositories for a module. For example:

Find-Module *BIOS*

Install a module by name:

Install-Module DellBIOSProvider

Useful options include:

  • -Repository to choose the source repository.
  • -RequiredVersion to specify a particular version.
  • -Scope CurrentUser to install for your account only; -Scope AllUsers installs for all users.
  • -Force to install without confirmation prompts.

View third-party modules installed on the computer:

Get-InstalledModule

For additional details:

Get-InstalledModule |  Select Name, Version, PublishedDate, InstalledDate, InstalledLocation

Windows also includes built-in modules, commonly stored in C:WindowsSystem32WindowsPowerShellv1.0Modules. List all available modules with:

Get-Module -ListAvailable

Import a module into the current session:

Import-Module DellBIOSProvider

PowerShell can also load modules automatically when you first run one of their cmdlets. The $env:PSModulePath environment variable identifies the directories PowerShell searches for modules. Display its contents with:

$env:PSModulePath -split ";"

To see modules already loaded in the current session, run:

Get-Module

If a module cannot be loaded because script execution is disabled, review the machine’s execution policy. One option for allowing locally created scripts and signed scripts from other sources is:

Set-ExecutionPolicy RemoteSigned

Check the commands provided by a module with:

Get-Command -Module DellBIOSProvider

Multiple versions of a module can be installed at once. List them with:

Get-Module PSWindowsUpdate -ListAvailable

Install modules manually or offline

For computers without access to the online repository, save a module on an internet-connected computer:

Save-Module -Name PSWindowsUpdate -Path C:Temp

Copy the module folder to the offline computer’s module directory. Alternatively, download its .nupkg package, place it in a local folder, and register that folder as a repository:

Register-PSRepository -Name myLocalPSRepo `  -SourceLocation C:PSRepo `  -InstallationPolicy TrustedInstall-Module PSWindowsUpdate -Repository myLocalPSRepo

See the guide to installing PowerShell modules offline.

Update modules

Update a specific module to the latest version in its repository:

Update-Module -Name PSWindowsUpdate

Update all installed modules:

Update-Module -Force

After an update, reload the module or restart the PowerShell session:

Import-Module -Name PSWindowsUpdate -Force

Remove modules

Uninstall a module with:

Uninstall-Module -Name PSWindowsUpdate

If it is loaded in the current session, remove it from memory first:

Remove-Module -Name PSWindowsUpdateUninstall-Module -Name PSWindowsUpdate -Force

More details are available in this guide to removing PowerShell modules.

Useful modules for administrators

Commonly used modules include:

  • NetSecurity — manage Windows Firewall rules.
  • ScheduledTasks — manage scheduled tasks.
  • RSAT-AD-PowerShell — work with Active Directory.
  • PSWindowsUpdate — manage Windows updates.
  • CredentialManager — work with Windows Credential Manager.
  • SimplySql — connect to databases such as MySQL, PostgreSQL, Oracle, SQL Server, and SQLite.
  • VMware.PowerCLI — administer VMware environments.
  • WinGet — manage Windows software packages.

Put this guide to work on a fast VPS

Deploy a pure-NVMe Windows or Linux VPS in minutes — full admin access, instant setup, from $6/mo.