Get-Package Scope parameter not working as expected
jonwbstr opened this issue · 2 comments
Hello, this is related to Doc Issue #7148
I expected the -Scope parameter of Get-Package to return software installed either to all users or for the current user. However, when I run the command without a scope I get 3 packages, and when I specify either of the two supported values, I get 0 packages. Surely the packages are installed under one scope or the other. If not, there should be another value available for the scope the packages are installed under?
Steps to reproduce
PS C:\Users\JonWebster> get-package office*
Name Version Source ProviderName
---- ------- ------ ------------
Office 16 Click-to-Run Exte... 16.0.13530.20218 msi
Office 16 Click-to-Run Loca... 16.0.13530.20218 msi
Office 16 Click-to-Run Lice... 16.0.13530.20218 msi
PS C:\Users\JonWebster> get-package office* -Scope currentuser
get-package : No package found for 'office*'.
At line:1 char:1
+ get-package office* -Scope currentuser
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Microsoft.Power...lets.GetPackage:GetPackage) [Get-Package], Exception
+ FullyQualifiedErrorId : NoMatchFound,Microsoft.PowerShell.PackageManagement.Cmdlets.GetPackage
PS C:\Users\JonWebster> get-package office* -Scope allusers
get-package : No package found for 'office*'.
At line:1 char:1
+ get-package office* -Scope allusers
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Microsoft.Power...lets.GetPackage:GetPackage) [Get-Package], Exception
+ FullyQualifiedErrorId : NoMatchFound,Microsoft.PowerShell.PackageManagement.Cmdlets.GetPackage
Expected behavior
If providing no scope returns 3 packages, I expect the combined total of the two scope to also be 3 packages.
Also, expected a scope of "Both" and that to be the default for the -Scope parameter.
But that may be more of a feature request ;)
Actual behavior
Excluding the -Scope parameter returns 3 packages. Using the scope parameter returns 0 packages.
Environment data
> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.19041.1
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.19041.1
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
> Get-Module -ListAvailable PowerShellGet,PackageManagement
Directory: C:\Program Files\WindowsPowerShell\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 1.4.7 PackageManagement {Find-Package, Get-Package, Get-PackageProvider, Get-Packa...
Binary 1.0.0.1 PackageManagement {Find-Package, Get-Package, Get-PackageProvider, Get-Packa...
Script 2.2.5 PowerShellGet {Find-Command, Find-DSCResource, Find-Module, Find-RoleCap...
Script 1.0.0.1 PowerShellGet {Install-Module, Find-Module, Save-Module, Update-Module...}
> Get-PackageProvider -ListAvailable
Name Version DynamicOptions
---- ------- --------------
msi 3.0.0.0 AdditionalArguments
msu 3.0.0.0
nuget 2.8.5.208
NuGet 3.0.0.1 Destination, ExcludeVersion, Scope, SkipDependencies, Headers, FilterOnTag...
PowerShellGet 2.2.5.0 PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, ...
PowerShellGet 1.0.0.1
Programs 3.0.0.0 IncludeWindowsInstaller, IncludeSystemComponent
Thanks @jonwbstr looks like this may be an issue with the MSI provider which uses the available properties for MSI packages by calling the Windows Installer API (see https://github.com/OneGet/oneget/blob/WIP/src/Microsoft.PackageManagement.MsiProvider/Deployment/WindowsInstaller/ProductInstallation.cs)...at this time it doesnt look like MSI installs have a scope attribute, and are not recording the installation path...unfortunately PackageManagement is no longer in development so this likely will not directly be fixed