Skip to content
February 27, 2026 • Junior (1-3 years) How-To

PowerShell modules: install, update and remove (2026)

By Last updated

Install, update, pin and remove PowerShell Gallery modules with PowerShellGet or PSResourceGet, fix the NuGet provider prompt, and replace AzureAD modules.

Free PDF

Top 10 Intune and Autopilot Enrollment Errors: Causes and Fixes

A free cheat sheet covering ten enrollment errors, each with the symptom, the most likely cause, the fix, and a link to the full guide.

  • Ten real error codes and failures, including 0x80180014, 0x8018002b, 0x801c03f3, 0x800705b4, the ODJConnector logon failure, and the Win32 detection error 0x87d1041c.
  • Every cause and fix checked against Microsoft's own documentation.
  • A link from each entry to the full zakitpro.com article.

You get the free PDF. By subscribing you also agree to receive occasional emails from zakitpro about Intune and Autopilot troubleshooting. Emails are sent through MailerLite. You can unsubscribe anytime with the link in every email. See the privacy page for how your email is handled.

Step-by-step guide

To install a module for yourself without admin rights, run Install-PSResource -Name <Module> on PowerShell 7.4 or later, which uses the CurrentUser scope by default. On Windows PowerShell 5.1, run Install-Module -Name <Module> -Scope CurrentUser. Update a module with Update-PSResource or Update-Module. List installed versions with Get-InstalledPSResource or Get-InstalledModule -AllVersions. If Windows PowerShell 5.1 says NuGet provider is required to continue, its PowerShellGet is the outdated 1.0.0.1. Update PowerShellGet first (steps below).

Which commands to use

Microsoft’s package manager guide says:

  • PowerShell 7.4 or later ships Microsoft.PowerShell.PSResourceGet, the new package manager (*-PSResource commands). Use these commands on PowerShell 7.4 and later.
  • PowerShell 6.0 or later includes a newer PowerShellGet (*-Module commands).
  • Windows PowerShell 5.1 ships PowerShellGet and PackageManagement 1.0.0.1, and you must upgrade them.

This article shows both command sets. For a first look at PowerShell itself, see Getting started with PowerShell.

Fix Windows PowerShell 5.1 first

Symptom: Install-Module stops with:

NuGet provider is required to continue
PowerShellGet requires NuGet provider version '2.8.5.201' or newer to interact with NuGet
-based repositories.

Microsoft’s fix, in an elevated Windows PowerShell 5.1 session:

# The PowerShell Gallery requires TLS 1.2 or higher
[Net.ServicePointManager]::SecurityProtocol =
    [Net.ServicePointManager]::SecurityProtocol -bor
    [Net.SecurityProtocolType]::Tls12

# Check what you have
Get-Module -Name PowerShellGet, PackageManagement, Microsoft.PowerShell.PSResourceGet -ListAvailable

# Install the latest releases (answer Y to the NuGet provider prompt)
Install-Module PowerShellGet -Repository PSGallery -Force -AllowClobber
Install-Module Microsoft.PowerShell.PSResourceGet -Repository PSGallery

Close and reopen PowerShell before you use the new versions.

Find and install

# PSResourceGet
Find-PSResource -Name Microsoft.Graph -Repository PSGallery
Install-PSResource -Name Microsoft.Graph                         # CurrentUser by default
Install-PSResource -Name Microsoft.Graph -Version '[2.0.0, 2.9.0]' # NuGet version range

# PowerShellGet
Find-Module -Name Microsoft.Graph
Install-Module -Name Microsoft.Graph -Scope CurrentUser
Install-Module -Name Microsoft.Graph -MinimumVersion 2.0.0 -MaximumVersion 2.9.0

Scopes: CurrentUser installs only for you. AllUsers installs to $env:ProgramFiles\PowerShell\Modules for everyone and needs elevation. If you don’t pass a scope to Install-Module, the default depends on the PowerShellGet version. PowerShellGet 1.x defaults to AllUsers. Pass -Scope explicitly in scripts.

Update

Update-PSResource -Name Microsoft.Graph     # PSResourceGet
Update-Module -Name Microsoft.Graph         # PowerShellGet
Update-Module                               # every module installed with Install-Module

Update-Module only updates modules that were installed with Install-Module. For anything else it errors. To see which modules have newer versions in the Gallery, compare Get-InstalledModule with Find-Module. The old Get-Module -ListAvailable | Where-Object { $_.UpdateAvailable } pattern doesn’t work, because Get-Module doesn’t return an UpdateAvailable property.

List, import, remove

Get-InstalledPSResource -Name Microsoft.Graph       # PSResourceGet, all installed versions
Get-InstalledModule -Name Microsoft.Graph -AllVersions
Get-Module                                          # modules loaded in this session
Import-Module Microsoft.Graph.Authentication        # load one submodule, not the whole SDK
Remove-Module Microsoft.Graph.Authentication        # unload from the session only
Uninstall-PSResource -Name Microsoft.Graph -Version 2.0.0
Uninstall-Module -Name Microsoft.Graph -RequiredVersion 2.0.0

Remove-Module only unloads a module from the current session. To delete it from disk, use Uninstall-PSResource or Uninstall-Module.

Repository trust

Set-PSResourceRepository -Name PSGallery -Trusted   # PSResourceGet
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted   # PowerShellGet

Trusting a repository removes the install confirmation prompt for everything in it. On shared or production machines, leave the PowerShell Gallery untrusted and confirm each install, or use an internal repository with only the modules you’ve approved. The -SkipPublisherCheck switch on Install-Module lets you install a newer version even when it isn’t signed by the trusted publisher of the version already installed. Don’t add it to scripts by default.

Replace AzureAD and MSOnline

Microsoft deprecated the AzureAD and MSOnline PowerShell modules on March 30, 2024 (Microsoft Learn). New scripts should use the Microsoft Graph PowerShell SDK (Microsoft.Graph). For Intune examples, see Microsoft Graph API for Intune.

Production habits

  1. Pin versions in scripts that run unattended, with -RequiredVersion or an exact -Version.
  2. Record dependencies. A #Requires -Modules statement or a required-resource .psd1 (Install-PSResource -RequiredResourceFile) makes them explicit.
  3. Use CurrentUser unless the module really has to be available to every user, such as a module that a SYSTEM-context Intune script needs.

FAQ

Should I use Install-Module or Install-PSResource?

On PowerShell 7.4 or later, use Install-PSResource (PSResourceGet), which Microsoft calls the new package management solution. Install-Module still works and is what Windows PowerShell 5.1 uses after you update PowerShellGet.

Why does Install-Module ask for the NuGet provider?

Windows PowerShell 5.1 ships PowerShellGet 1.0.0.1, which needs an updated NuGet provider. Enable TLS 1.2, answer Y, then update PowerShellGet.

Does Update-Module update every module?

Only modules installed with Install-Module. Running it with no name updates all of those.

Does Remove-Module uninstall a module?

No. It unloads the module from the current session. Use Uninstall-Module or Uninstall-PSResource to remove it from disk.

Is the AzureAD module still supported?

No. AzureAD and MSOnline were deprecated on March 30, 2024. Use the Microsoft Graph PowerShell SDK.

Sources

Free PDF

Top 10 Intune and Autopilot Enrollment Errors: Causes and Fixes

A free cheat sheet covering ten enrollment errors, each with the symptom, the most likely cause, the fix, and a link to the full guide.

  • Ten real error codes and failures, including 0x80180014, 0x8018002b, 0x801c03f3, 0x800705b4, the ODJConnector logon failure, and the Win32 detection error 0x87d1041c.
  • Every cause and fix checked against Microsoft's own documentation.
  • A link from each entry to the full zakitpro.com article.

You get the free PDF. By subscribing you also agree to receive occasional emails from zakitpro about Intune and Autopilot troubleshooting. Emails are sent through MailerLite. You can unsubscribe anytime with the link in every email. See the privacy page for how your email is handled.

#powershell #modules #psgallery #install