Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Find-PSResource -IncludeDependencies differs from actual Install-PSResource result? #1639

Open
3 tasks done
S-dn-Y opened this issue Apr 20, 2024 · 1 comment
Open
3 tasks done
Assignees
Projects

Comments

@S-dn-Y
Copy link

S-dn-Y commented Apr 20, 2024

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest released version
  • Search the existing issues.

Steps to reproduce

When invoking Find-PSResource with the -IncludeDendencies switch I see different results compared to what Install-PSResource is actually doing.
I'm trying to catch what Install-PSResource would do when our pipeline tries to install a module that is already installed.
I want to clean up old versions (even if this module is already installed) to keep our environment tidy but this requires me to know what Install-PSResource would install. I used to invoke Install-PSResource with the -Reinstall -PassThru switches but the Az modules installs quite a bit of prerequisites so it introduces more chance of pipeline failures (proxy timeouts etc) that I'd rather just check the prerequisites.
Therefore I started using Find-PSResource with the -IncludeDependencies switch, expecting it to give me what I need, but it apparently resolves every dependency of every module and therefore duplicates a Az.Accounts 25 times because a lot of the module apparently specify a different version dependency, but should Find-PSResource not give me back what Install-PSResource would result in though?

Expected behavior

PS C:\Windows\system32> (Find-PSResource -Name Az -IncludeDependencies | Group-Object -Property Name).Where({ $_.Name -eq 'Az.Accounts' })

Count Name                      Group
----- ----                      -----
   1 Az.Accounts               {Microsoft.PowerShell.PSResourceGet.UtilClasses.PSResourceInfo


PS C:\Windows\system32> (Install-PSResource -Name Az -Scope AllUsers -TrustRepository -Reinstall -PassThru | Group-Object -Property Name).Where({ $_.Name -eq 'Az.Accounts' })

Count Name                      Group
----- ----                      -----
    1 Az.Accounts               {Microsoft.PowerShell.PSResourceGet.UtilClasses.PSResourceInfo}

Actual behavior

PS C:\Windows\system32> (Find-PSResource -Name Az -IncludeDependencies | Group-Object -Property Name).Where({ $_.Name -eq 'Az.Accounts' })

Count Name                      Group
----- ----                      -----
   25 Az.Accounts               {Microsoft.PowerShell.PSResourceGet.UtilClasses.PSResourceInfo, Microsoft.PowerShell.PSResourceGet.UtilClasses.PSResourceInfo, Micr...


PS C:\Windows\system32> (Install-PSResource -Name Az -Scope AllUsers -TrustRepository -Reinstall -PassThru | Group-Object -Property Name).Where({ $_.Name -eq 'Az.Accounts' })

Count Name                      Group
----- ----                      -----
    1 Az.Accounts               {Microsoft.PowerShell.PSResourceGet.UtilClasses.PSResourceInfo}

Error details

No response

Environment data

PS C:\Windows\system32> Get-Module Microsoft.PowerShell.PSResourceGet; $PSVersionTable | Format-Table

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Binary     1.0.4.1    Microsoft.PowerShell.PSResourceGet  {Find-PSResource, Get-InstalledPSResource, Get-PSResourceR...



Name                           Value
----                           -----
PSVersion                      5.1.20348.2400
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.20348.2400
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Visuals

No response

@anamnavi
Copy link
Member

@S-dn-Y thanks for creating this issue, we'll take a look into this behavior!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
1.1
Awaiting triage
Development

No branches or pull requests

3 participants