# PowerShellGallery – You are installing modules from an untrusted repository

Learn why PowerShell prompts that PSGallery is untrusted, how to mark it as trusted, and when you may want to leave that warning in place.

blog

19 Aug 2018 en

![PowerShellGallery – You are installing modules from an untrusted repository](/wp-content/uploads/2018/08/img_5b79ad11d0060.png)

[View images (3)](#pf-content-image-1-0)

When you start working with **PowerShell** modules, one of the first annoyances you run into is the repeated prompt asking whether you trust **PSGallery**. The message is not telling you the gallery is malicious. It simply means your local repository configuration is still marked as **Untrusted**, so PowerShell asks for confirmation before it installs anything.

```powershell
Install-Module PSWriteWord -AllowPrerelease
```

[!\[Install-Module prompt warning that PSGallery is an untrusted repository before installing PSWriteWord.\](/wp-content/uploads/2018/08/img_5b79ab3b7bfd1.png)](/wp-content/uploads/2018/08/img_5b79ab3b7bfd1.png)

If you install modules often, answering that prompt every time gets old very quickly.

## Check the current repository policy

```powershell
Get-PSRepository
```

[!\[Get-PSRepository output showing PSGallery repository details including its current installation policy.\](/wp-content/uploads/2018/08/img_5b79ac1626261.png)](/wp-content/uploads/2018/08/img_5b79ac1626261.png)

Look at the `InstallationPolicy` value for `PSGallery`. If it is set to `Untrusted`, PowerShell will continue prompting.

## Trust PSGallery for PowerShellGet

```powershell
Set-PSRepository -Name 'PSGallery' -InstallationPolicy Trusted
```

[!\[Set-PSRepository command output after changing PSGallery installation policy to Trusted.\](/wp-content/uploads/2018/08/img_5b79ad11d0060.png)](/wp-content/uploads/2018/08/img_5b79ad11d0060.png)

That is enough for the classic **PowerShellGet** workflow. The setting is stored for the current user and suppresses future confirmation prompts for that repository.

## If you use the newer PSResourceGet commands

On newer systems you may be using **PSResourceGet** cmdlets instead of `Install-Module`. In that case, the equivalent command is:

```powershell
Set-PSResourceRepository -Name PSGallery -Trusted -PassThru
```

## Should you always trust PSGallery?

Usually yes for personal admin work, but it is worth understanding what this switch does and does not do:

- It marks the repository as trusted for your local tooling.
- It removes the confirmation prompt.
- It does not audit the contents of every module for you.
- In a locked-down environment, an internal repository can still be the better choice.

My practical rule is simple: trust the repository only if you already trust your source and you still review what you install.

## Related Projects

Projects that align with this post's tags, categories, and content.

[All projects](/projects/)

Matching projects...

[Back to Blog](/blog)

## Related posts

- [Configuring Office 365 settings using PowerShell – The non-supported way](/blog/configuring-office-365-settings-using-powershell-the-non-supported-way/)
- [Check an API write after a PowerShell timeout](/blog/verify-uncertain-api-outcomes-powershell/)
- [Compose PDF reports and automate page workflows with PSWriteOffice](/blog/automate-pdf-reports-and-page-workflows-pswriteoffice/)

<!-- PowerForge markdown artifact sha256:1DEB3452110661331BDAD46F23E55340E91D09534CC27236B3CC50D3E9264998 -->
