Affected versions: Windows Server 2019

πŸ“– ~1 min read

Table of contents
  1. Symptom & Impact
  2. Environment & Reproduction
  3. Root Cause Analysis
  4. Quick Triage
  5. Step-by-Step Diagnosis
  6. Solution β€” Primary Fix
  7. Solution β€” Alternative Approaches
  8. Verification & Acceptance Criteria
  9. Rollback Plan
  10. Prevention & Hardening
  11. Related Errors & Cross-Refs
  12. References & Further Reading

Symptom & Impact

Install-Module on Windows Server 2019 prompts repeatedly or fails because the PSGallery is marked untrusted, breaking automation scripts.

Environment & Reproduction

Reproduces when a fresh server runs PSGallery installs in non-interactive mode and InstallationPolicy is still Untrusted.

Install-Module Az -Force

Root Cause Analysis

PowerShellGet treats PSGallery as untrusted by default, so silent installs error out unless the policy is updated or the cmdlet uses -Force.

Quick Triage

Inspect repository policy and PowerShellGet module version on the server.

Get-PSRepository
Get-Module PowerShellGet -ListAvailable

Step-by-Step Diagnosis

Re-run the module install with -Verbose to confirm the trust prompt is the blocker.

Install-Module Az -Verbose -ErrorAction Stop
Illustrative mockup for windows-server-2019 β€” terminal_or_powershell
Diagnostic output for packaging/psget-repo-policy β€” Illustrative mockup β€” Progressive Robot

Solution β€” Primary Fix

Trust the PSGallery repository for the machine and ensure PowerShellGet is up to date.

Still having issues? Our IT Solutions & Services team can diagnose and resolve this for you. Get in touch for a free consultation.

Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
Install-Module PowerShellGet -Force -AllowClobber
Install-Module Az -Scope AllUsers -Force
Illustrative mockup for windows-server-2019 β€” error_dialog
Resolution for packaging/psget-repo-policy β€” Illustrative mockup β€” Progressive Robot

Solution β€” Alternative Approaches

Register an internal NuGet feed and source modules from there to avoid trusting the public gallery.

Register-PSRepository -Name InternalPS -SourceLocation https://nuget.local/psgallery -InstallationPolicy Trusted

Verification & Acceptance Criteria

Modules install non-interactively and Get-InstalledModule returns expected versions.

Get-InstalledModule Az

Rollback Plan

Reset PSGallery to Untrusted if required by audit policy.

Set-PSRepository -Name PSGallery -InstallationPolicy Untrusted

Prevention & Hardening

Configure DSC or GPO to set repository trust uniformly across servers.

# DSC PSModule resource ensures repository policy

Related: NuGet provider missing, TLS 1.2 errors during module pull, and proxy authentication failures.

Related tutorial: View the step-by-step tutorial for Windows Server 2019.

View all Windows Server 2019 tutorials on the Tutorials Hub β†’

Browse all common problems & solutions on the Tutorials Hub.

References & Further Reading

Microsoft Learn documentation for PowerShellGet, repositories, and module trust policies.

Need Expert Help?

If you cannot resolve this yourself, our team offers hands-on Server Management, Managed IT Services, and flexible Support Plans. Contact us today β€” we respond within one business day.