PowerShell / PowerShell/PSResourceGet

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

Open
#1,639 3 comments 0 reactions 1 assignee View on GitHub

@alerickson is already working on this.

Since Apr 23, 2024.

Area-Find
Dominant language
C#
Stars
576
Forks
114
Avg merge
1d 2h
Merged PRs (30d)
7

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.