π ~1 min read
Table of contents
Symptom & Impact
Install-Module on Windows Server 2012 R2 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

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

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 Errors & Cross-Refs
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 2012 R2.
View all Windows Server 2012 R2 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.