PSResourceGet
PSResourceGet copied to clipboard
Install-PSResource prompts for untrusted repository even though resource is installing from a trusted repo
Prerequisites
- [X] Write a descriptive title.
- [X] Make sure you are able to repro it on the latest released version
- [X] Search the existing issues.
Steps to reproduce
I am trying to install a resource and I have two repositories registered my computer's test repo and PSGallery. The test repo does not have specified resource but for some reason its prompting against that repository instead of passing since it resides in trusted PSGallery.
Expected behavior
Installs without any prompts
Actual behavior
PS C:\Users\Thomas> install-PSResource Microsoft.PowerShell.SecretStore
Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its Trusted value by running the Set-PSResourceRepository cmdlet. Are you sure you want to install the
PSresource from 'test' ?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"):
PS C:\Users\Thomas> ^C
PS C:\Users\Thomas> Set-PSResourceRepository -Name PSGallery -Trusted
PS C:\Users\Thomas> install-PSResource Microsoft.PowerShell.SecretStore
Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its Trusted value by running the Set-PSResourceRepository cmdlet. Are you sure you want to install the
PSresource from 'test' ?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"):
PS C:\Users\Thomas> Find-PSResource -Name Microsoft.PowerShell.SecretStore
Name Version Prerelease Repository Description
---- ------- ---------- ---------- -----------
Microsoft.PowerShell.SecretStore 1.0.6.0 PSGallery …
PS C:\Users\Thomas> Get-PSResourceRepository
Name Uri Trusted Priority
---- --- ------- --------
test file:///C:/test/repo False 49
PSGallery https://www.powershellgallery.com/api/v2 True 50
PS C:\Users\Thomas> Find-PSResource -Name Microsoft.PowerShell.SecretStore -Repository test
Error details
N/A
Environment data
Name Version
---- -------
PowerShellGet 3.0.14
Name Value
---- -----
PSVersion 7.2.5
PSEdition Core
GitCommitId 7.2.5
OS Microsoft Windows 10.0.19043
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Visuals
No response
It seems that the prompt is happening at the wrong place in the code. It looks like when the cmdlet does a search, it prompts. It should really prompt when doing the install:
PS> install-psresource microsoft.powershell.archive -Prerelease
Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its Trusted value by running the Set-PSResourceRepository cmdlet. Are you sure you want to
install the PSresource from 'NuGet' ?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): y
Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its Trusted value by running the Set-PSResourceRepository cmdlet. Are you sure you want to
install the PSresource from 'PSGallery' ?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): y
In this case, NuGet should never had been prompted since I know that module isn't there.
This one should be resolved by #831