How To Add A Trusted Repository In PowerShell In Windows 10
If you don’t know how to use PowerShell, or you want to simplify whatever it is you’re trying to accomplish with a script or command, a PowerShell module is a good way to do it. You can install just about any module in PowerShell however, as an added security layer, it will warn you against it if the module is from an untrusted repository. This isn’t much of a problem. You can dismiss the warning, or you can just add the repository as a trusted repository in PowerShell. It’s pretty simple. All you need is the name of a repository you want to add.
Repository Name
If you already know the name of the repository that you want to install modules from, you can skip right ahead to the next section. If you only know the name of the module you want to install, but not the name of the repository it comes from, you need to find the name. This too is simple.
Open PowerShell and enter the following command;
Syntax:
Find-Module -Name "Module Name"
Replace Module Name with the name of the module you want to install.
Example:
Find-Module -Name "BurntToast"
It might take a few seconds for PowerShell to find the repository name but once it does, it will return the version number, the name of the module, and of course, the repository name.
Now that you know the repository name, you can add it as a trusted repository in PowerShell.
Trusted Repository In PowerShell
To add a trusted repository in PowerShell, run the following command;
Syntax:
Set-PSRepository -Name "Repository Name" -InstallationPolicy Trusted
Example:
Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted
Remove Trusted Repository
Use the following command to remove a trusted repository in PowerShell;
Syntax:
Unregister-PSRepository -Name "Repository Name"
Example:
Unregister-PSRepository -Name "PSGallery"
Why Add A Repository?
You shouldn’t add every single repository that you install a module from as a trusted repository. The only good reason to add a trusted repository to PowerShell is if you plan to install items from it regularly. If you only download items on occasion then simply answer the confirmation prompt that you see when you install the item.
It’s also a good idea to edit the repositories you’ve added. They can add up and from a security point, you shouldn’t have ones you don’t need. To get a list of all trusted repositories in PowerShell, run the following command;
Get-PSRepository
A module, once installed, will run without any problems. It will not prompt you for a confirmation every time you use it hence the repository it belongs to doesn’t necessarily need to be added as a trusted one.