You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add new scope argument to Get-PSResource that returns CurrentUser and AllUsers resources #860
Get-PSResource should return both CurrentUser and AllUsers installed resources by default. If the scope parameter is used then it should limit to search.
Expected behavior
Returns both CurrentUser and AllUsers resources.
Actual behavior
Returns both CurrentUser resources.
Error details
No response
Environment data
Name Version
-----------
PowerShellGet 3.0.16
Name Value
---------
PSVersion 7.3.0
PSEdition Core
GitCommitId 7.3.0
OS Microsoft Windows 10.0.19044
Platform Win32NT
PSCompatibleVersions {1.0,2.0,3.0,4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Somewhat related, ideally the "CurrentUser" path should be detectable from pwsh and not guessed by PowerShellGet, so please support PowerShell/PowerShell#18613 as a change as well.
alerickson what existing behavior are you referring to? The reason it should be updated is that Get-Module returns both current user and all users modules.
Consider this use case. A user wants to use a specific module however when they get the list of installed it doesn't appear and so they install it. However, the system admin already installed that module in the all users scope. This creates a redundant situation.
Thomas Nieto (@ThomasNieto)Get-Module is not really a good comparison as it doesn't have a -Scope parameter like Get-PSResource does. In general we want to be consistent with PowerShell -Scope parameter where the default scope is CurrentUser.
However, we can certainly consider adding a new AllScopes-Scope parameter argument to return installed resources for both current user and machine scopes. I'll re-open this as an enhancement issue.
In the meantime a workaround is to simply call Get-PSResource twice with the two different scope arguments.
changed the title [-]Get-PSResource without scope should return CurrentUser and AllUsers resources[/-][+]Add new scope argument to Get-PSResource that returns CurrentUser and AllUsers resources[/+]on Jan 19, 2023
Activity
JustinGrote commentedon Nov 18, 2022
Somewhat related, ideally the "CurrentUser" path should be detectable from pwsh and not guessed by PowerShellGet, so please support PowerShell/PowerShell#18613 as a change as well.
alerickson commentedon Jan 18, 2023
This behavior (default scope is CurrentUser scope) is consistent with PowerShell scoping, so we want to remain consistent.
ThomasNieto commentedon Jan 18, 2023
alerickson what existing behavior are you referring to? The reason it should be updated is that
Get-Modulereturns both current user and all users modules.Consider this use case. A user wants to use a specific module however when they get the list of installed it doesn't appear and so they install it. However, the system admin already installed that module in the all users scope. This creates a redundant situation.
PaulHigin commentedon Jan 19, 2023
Thomas Nieto (@ThomasNieto)
Get-Moduleis not really a good comparison as it doesn't have a-Scopeparameter likeGet-PSResourcedoes. In general we want to be consistent with PowerShell-Scopeparameter where the default scope isCurrentUser.However, we can certainly consider adding a new
AllScopes-Scopeparameter argument to return installed resources for both current user and machine scopes. I'll re-open this as an enhancement issue.In the meantime a workaround is to simply call
Get-PSResourcetwice with the two different scope arguments.[-]Get-PSResource without scope should return CurrentUser and AllUsers resources[/-][+]Add new scope argument to Get-PSResource that returns CurrentUser and AllUsers resources[/+]