How To Add A Trusted Repository In PowerShell In Windows 10

How To Add A Trusted Repository In PowerShell In Windows 10

Note: This article is written for web publishing and is based on real PowerShell behavior, Microsoft PowerShellGet documentation, PowerShell Gallery guidance, and practical Windows 10 administration experience.

PowerShell is one of those Windows tools that looks calm on the surface but secretly has a toolbox big enough to fix, automate, inspect, install, configure, and occasionally make you question your life choices. If you have ever tried to install a PowerShell module on Windows 10 and suddenly met the famous warning, “You are installing the modules from an untrusted repository,” congratulationsyou have officially entered the world of PowerShell repositories.

The good news is that this warning is not usually an error. It is PowerShell politely tapping you on the shoulder and saying, “Hey, are you sure this source is okay?” The better news is that if you trust the repository, you can mark it as trusted using a simple command. The important part is understanding what that command does, when to use it, and when not to trust a repository just because a random tutorial on the internet said so. Yes, even if that tutorial has a very confident headline.

In this guide, you will learn how to add a trusted repository in PowerShell in Windows 10, how to trust the default PSGallery repository, how to register a custom repository, how to verify your settings, and how to avoid common mistakes that can make module installation more frustrating than assembling office furniture without the tiny Allen key.

What Is a PowerShell Repository?

A PowerShell repository is a source location where PowerShell can find, install, update, and publish packages such as modules, scripts, Desired State Configuration resources, and related tools. In everyday Windows 10 usage, the most common repository is PSGallery, also known as the PowerShell Gallery.

When you run a command such as:

PowerShell uses the PowerShellGet module to search registered repositories and download the package. If PSGallery is registered, PowerShell can locate modules such as Az, Microsoft.Graph, ExchangeOnlineManagement, Pester, PSReadLine, and many others.

However, a repository is not automatically “trusted” just because it exists. A registered repository simply means PowerShell knows where to look. A trusted repository means PowerShell will install from that source without asking you for confirmation each time.

What Does “Trusted Repository” Mean in PowerShell?

In PowerShellGet, repositories have an InstallationPolicy. The two common values are:

  • Trusted: PowerShell does not prompt before installing modules from the repository.
  • UnTrusted: PowerShell prompts for confirmation before installing modules from the repository.

That is the key point: trusting a repository does not magically scan every module, verify every line of code, or wrap your computer in a glowing shield of cyber-security happiness. It only tells PowerShell, “Do not interrupt me with a confirmation prompt when I install from this source.”

This is useful for administrators, developers, and automation scripts. For example, if you regularly install approved modules from PSGallery or from an internal company repository, marking the source as trusted can save time and reduce interruptions.

Still, trust should be intentional. A repository can contain powerful code. PowerShell modules can create files, change settings, connect to services, and perform administrative actions. Treat repositories the way you treat snacks in an office fridge: trust only what you recognize, and be careful with anything unlabeled.

Why Windows 10 Shows the “Untrusted Repository” Warning

On Windows 10, Windows PowerShell 5.1 is commonly used with PowerShellGet. When you install a module from a repository whose installation policy is set to UnTrusted, you may see a warning like this:

This prompt appears because PowerShell wants you to confirm that you trust the source. You can usually type Y for Yes, or A for Yes to All, but that only handles the current installation session. If you want PowerShell to remember your trust decision for future installs, you need to change the repository installation policy.

Before You Begin: Open PowerShell Correctly

For most repository configuration tasks, you can use Windows PowerShell on Windows 10. Some commands work without elevation, but running PowerShell as administrator can help avoid permission issues, especially when installing modules for all users.

How to Open PowerShell as Administrator

  1. Click the Start button.
  2. Type PowerShell.
  3. Right-click Windows PowerShell.
  4. Select Run as administrator.
  5. Click Yes if Windows asks for permission.

You can also press Windows + X and choose Windows PowerShell (Admin) on many Windows 10 systems.

Step 1: Check Existing PowerShell Repositories

Before changing anything, check which repositories are currently registered. Run:

You may see output similar to this:

The important columns are Name, InstallationPolicy, and SourceLocation. If PSGallery appears and its policy is Untrusted, you can change it to trusted if you are comfortable using it as a source.

Step 2: Add PSGallery as a Trusted Repository

If PSGallery is already registered, the easiest way to make it trusted is:

After running the command, verify the result:

You should now see:

That is the standard method for changing the default PowerShell Gallery repository from untrusted to trusted in Windows 10.

Step 3: Install a Module to Test the Trusted Repository

Now test the configuration by installing a module. For example:

Or, if you are working with Microsoft cloud administration:

If the repository is trusted, PowerShell should no longer ask whether you trust PSGallery before installing. It may still ask about other things, such as installing the NuGet provider or accepting a license, depending on the package and your environment.

How to Register a New Trusted Repository

Sometimes you do not want to trust PSGallery directly. In business environments, schools, labs, and managed IT networks, administrators often prefer an internal repository. This internal source may contain only approved packages, tested module versions, or company-specific scripts.

To register a new repository and mark it as trusted, use Register-PSRepository. Here is a basic example:

Replace the name and URL with the real repository information. Once registered, you can install modules from it like this:

To verify the repository:

How to Change a Repository Back to Untrusted

Changed your mind? Good. That means you are thinking like a careful administrator. To set a repository back to untrusted, run:

Then verify it:

This restores the confirmation prompt when installing from that repository.

How to Re-Register the Default PSGallery Repository

If Get-PSRepository does not show PSGallery, it may have been removed or not registered correctly. You can try restoring the default repository with:

Then check again:

After PSGallery appears, you can trust it if needed:

Common Errors and How to Fix Them

1. “Unable to Find Module Repositories”

If PowerShell says it cannot find module repositories, first check whether PSGallery is registered:

If no repository appears, try:

If that fails, the issue may involve network access, proxy settings, outdated PowerShellGet components, TLS settings, or a blocked connection to the PowerShell Gallery.

2. NuGet Provider Prompt Appears

Windows PowerShell 5.1 may need the NuGet provider to interact with the PowerShell Gallery. If prompted, you can approve the installation. To install it manually, use:

Then try your module installation again.

3. Outdated PowerShellGet Version

Some Windows 10 systems include older versions of PowerShellGet and PackageManagement. To check versions, run:

To update PowerShellGet, you can run:

After updating, close and reopen PowerShell so the newer module version loads properly. PowerShell can be stubborn about loaded modules, rather like a browser tab you forgot was still playing audio somewhere.

4. Proxy or Firewall Problems

In corporate or school networks, PowerShell may not be able to reach PSGallery because of proxy rules, firewall restrictions, SSL inspection, or blocked package sources. In that case, trusting the repository will not fix the connection. Trust controls the confirmation prompt; it does not repair network access.

If your organization blocks PSGallery, ask your IT team whether they provide an internal PowerShell repository or offline module installation process.

Security Tips Before Trusting a PowerShell Repository

Adding a trusted repository is convenient, but it should not be treated as a casual click-next-next-finish decision. Here are smart safety practices:

  • Trust only known sources. PSGallery is widely used, but it contains community content, so review modules before using them in sensitive environments.
  • Prefer internal repositories for production. Businesses often mirror approved modules into a private repository to control versions and reduce supply-chain risk.
  • Check module publishers. Look at the author, project page, release history, download count, and documentation.
  • Install with least privilege. Use -Scope CurrentUser when you do not need machine-wide installation.
  • Pin versions when stability matters. Use -RequiredVersion for scripts that must behave consistently.
  • Review scripts before running them. A trusted repository removes prompts; it does not replace judgment.

Useful Commands Summary

Here is a practical command list you can keep nearby:

Best Practice: Trust the Repository, Not the Internet

The phrase “trusted repository” can sound more powerful than it really is. In PowerShell, it mainly means PowerShell will not ask for confirmation before installing from that repository. It does not mean every module is safe, reviewed, signed, maintained, or perfect for your system.

For personal Windows 10 usage, trusting PSGallery can be reasonable if you regularly install well-known modules. For business environments, production servers, and compliance-sensitive systems, it is better to use a curated internal repository. That way, administrators can test modules, approve versions, and avoid depending directly on external package sources during deployment.

In other words, the best PowerShell setup is not just fast. It is predictable. A trusted repository should make your workflow smoother, not turn your computer into a surprise party hosted by unknown scripts.

Experience Notes: Real-World Lessons When Adding a Trusted Repository in Windows 10

In real Windows 10 administration work, adding a trusted PowerShell repository is rarely difficult. The command itself is short. The tricky part is everything around it: old PowerShellGet versions, NuGet prompts, corporate proxies, inconsistent documentation copied from five-year-old blog posts, and the occasional machine that behaves like it has not had coffee yet.

One common experience is installing a module such as AzureAD, Microsoft.Graph, ExchangeOnlineManagement, or PSWindowsUpdate and immediately seeing the untrusted repository prompt. For a beginner, the warning can look scary, almost as if PowerShell has detected a dangerous file. In many cases, it is simply telling you that PSGallery is registered but not marked as trusted. Once you run Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted, the repeated prompt disappears.

Another practical lesson is that trusting PSGallery does not solve every installation problem. Many users run the trust command and then wonder why Install-Module still fails. The reason is usually unrelated. Maybe the NuGet provider is missing. Maybe TLS settings are outdated. Maybe the firewall blocks the connection. Maybe the system is behind a proxy. The repository policy is only one piece of the puzzle. It controls confirmation behavior, not internet connectivity.

On older Windows 10 installations, I have often seen PowerShellGet version 1.0.0.1 sitting there like an antique lamp in a modern smart home. It works for some tasks, but modern modules may expect newer tooling. Updating PowerShellGet and PackageManagement can make installs smoother, although you may need to restart PowerShell afterward. If a command still behaves strangely after an update, closing the session and opening a fresh administrator window is a simple fix that solves more problems than it has any right to.

In business settings, the best experience usually comes from using an internal repository. Instead of letting every workstation install directly from PSGallery, IT teams can download approved modules, test them, and publish them internally. Then users trust the internal repository, not the entire public gallery. This approach is cleaner for security, auditing, version control, and repeatable deployments. It also helps when machines do not have direct internet access.

For home users and small teams, the practical rule is simple: if you install popular, well-documented modules from PSGallery often, marking PSGallery as trusted can save time. But do not install random modules just because the command looks convenient. Check the module name carefully, read the description, verify the publisher, and avoid copy-pasting administrative commands you do not understand. PowerShell is powerful enough to be helpful and powerful enough to cause trouble, which is basically the definition of a good tool.

The smoothest workflow is usually this: check repositories with Get-PSRepository, trust only the repository you actually use, install modules with -Scope CurrentUser when possible, and keep a small record of the commands you ran. That way, if you need to repeat the setup on another Windows 10 computer, you are not relying on memory, luck, or a browser tab you closed three Tuesdays ago.

Conclusion

Adding a trusted repository in PowerShell in Windows 10 is straightforward once you understand the purpose of the repository installation policy. Use Get-PSRepository to view registered sources, use Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted to trust PSGallery, and use Register-PSRepository when adding a custom repository.

The key is to balance convenience with caution. A trusted repository removes repeated confirmation prompts, which is great for everyday administration and automation. But it does not guarantee that every module is safe or appropriate for your system. Trust repositories deliberately, review modules carefully, and use internal repositories when security and consistency matter.

PowerShell rewards people who move carefully. Once your repository settings are clean, module installation becomes faster, scripts become easier to automate, and Windows 10 administration feels much less like arguing with a vending machine that took your dollar.