PSResourceGet
PSResourceGet copied to clipboard
Find-PSResource -IncludeDependencies differs from actual Install-PSResource result?
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
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
@S-dn-Y thanks for creating this issue, we'll take a look into this behavior!
Seems Find-PSResource -IncludeDependencies finds dependencies of dependencies too, recursively. So with Az you end up with 9 versions of Az.Accounts.
Expand
PS > $FindWithDependencies = [array](Find-PSResource -Repository 'PSGallery' -Name 'Az' -IncludeDependencies)
PS > $FindWithDependencies | Sort-Object -Property 'Name', 'Version'
Name Version Prerelease Repository Description
---- ------- ---------- ---------- -----------
Az 12.4.0 PSGallery Microsoft Azure PowerShell - Cmdlets to manage resources in Azure. This module is compatible with PowerShell and Windows…
Az.Accounts 2.13.0 PSGallery Microsoft Azure PowerShell - Accounts credential management cmdlets for Azure Resource Manager in Windows PowerShell and…
Az.Accounts 2.13.2 PSGallery Microsoft Azure PowerShell - Accounts credential management cmdlets for Azure Resource Manager in Windows PowerShell and…
Az.Accounts 2.16.0 PSGallery Microsoft Azure PowerShell - Accounts credential management cmdlets for Azure Resource Manager in Windows PowerShell and…
Az.Accounts 2.17.0 PSGallery Microsoft Azure PowerShell - Accounts credential management cmdlets for Azure Resource Manager in Windows PowerShell and…
Az.Accounts 2.19.0 PSGallery Microsoft Azure PowerShell - Accounts credential management cmdlets for Azure Resource Manager in Windows PowerShell and…
Az.Accounts 3.0.0 PSGallery Microsoft Azure PowerShell - Accounts credential management cmdlets for Azure Resource Manager in Windows PowerShell and…
Az.Accounts 3.0.1 PSGallery Microsoft Azure PowerShell - Accounts credential management cmdlets for Azure Resource Manager in Windows PowerShell and…
Az.Accounts 3.0.3 PSGallery Microsoft Azure PowerShell - Accounts credential management cmdlets for Azure Resource Manager in Windows PowerShell and…
Az.Accounts 3.0.4 PSGallery Microsoft Azure PowerShell - Accounts credential management cmdlets for Azure Resource Manager in Windows PowerShell and…
Az.Advisor 2.0.1 PSGallery Microsoft Azure PowerShell: Advisor cmdlets
Az.Aks 6.0.4 PSGallery Microsoft Azure PowerShell - Azure managed Kubernetes cmdlets for Windows PowerShell and PowerShell Core.…
Az.AnalysisServices 1.1.5 PSGallery Microsoft Azure PowerShell - Analysis Services cmdlets for Windows PowerShell and PowerShell Core.…
Az.ApiManagement 4.0.4 PSGallery Microsoft Azure PowerShell - Api Management service cmdlets for Azure Resource Manager in Windows PowerShell and PowerSh…
Az.App 1.1.0 PSGallery Microsoft Azure PowerShell: App cmdlets
Az.AppConfiguration 1.3.2 PSGallery Microsoft Azure PowerShell: AppConfiguration cmdlets
Az.ApplicationInsights 2.2.5 PSGallery Microsoft Azure PowerShell: ApplicationInsights cmdlets
Az.ArcResourceBridge 1.0.1 PSGallery Microsoft Azure PowerShell: ArcResourceBridge cmdlets
Az.Attestation 2.0.2 PSGallery Microsoft Azure PowerShell - Attestation service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell…
Az.Automanage 1.0.2 PSGallery Microsoft Azure PowerShell: Automanage cmdlets
Az.Automation 1.10.0 PSGallery Microsoft Azure PowerShell - Automation service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell …
Az.Batch 3.6.3 PSGallery Microsoft Azure PowerShell - Batch service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core.…
Az.Billing 2.1.0 PSGallery Microsoft Azure PowerShell - Billing service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Cor…
Az.Cdn 3.2.2 PSGallery Microsoft Azure PowerShell: Cdn cmdlets
Az.CloudService 2.0.1 PSGallery Microsoft Azure PowerShell: CloudService cmdlets
Az.CognitiveServices 1.14.1 PSGallery Microsoft Azure PowerShell - Cognitive Services management cmdlets for Azure Resource Manager in Windows PowerShell and …
Az.Compute 8.4.0 PSGallery Microsoft Azure PowerShell - Compute service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Cor…
Az.ConfidentialLedger 1.0.1 PSGallery Microsoft Azure PowerShell: ConfidentialLedger cmdlets
Az.ContainerInstance 4.0.2 PSGallery Microsoft Azure PowerShell: ContainerInstance cmdlets
Az.ContainerRegistry 4.2.1 PSGallery Microsoft Azure PowerShell - Container Registry service cmdlets for Azure Resource Manager in Windows PowerShell and Pow…
Az.CosmosDB 1.15.0 PSGallery Microsoft Azure PowerShell - CosmosDB service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Co…
Az.DataBoxEdge 1.1.1 PSGallery Microsoft Azure PowerShell - DataBoxEdge service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell…
Az.Databricks 1.9.0 PSGallery Microsoft Azure PowerShell: Databricks cmdlets
Az.DataFactory 1.18.8 PSGallery Microsoft Azure PowerShell - Data Factory service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShel…
Az.DataLakeAnalytics 1.0.3 PSGallery Microsoft Azure PowerShell - Data Lake Analytics in Windows PowerShell and PowerShell Core.…
Az.DataLakeStore 1.3.2 PSGallery Microsoft Azure PowerShell - Azure Data Lake Store cmdlets in Windows PowerShell and PowerShell Core.…
Az.DataProtection 2.4.0 PSGallery Microsoft Azure PowerShell: DataProtection cmdlets
Az.DataShare 1.0.2 PSGallery Microsoft Azure PowerShell - DataShare service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell C…
Az.DesktopVirtualization 4.3.1 PSGallery Microsoft Azure PowerShell: DesktopVirtualization cmdlets
Az.DevCenter 1.2.0 PSGallery Microsoft Azure PowerShell: DevCenter cmdlets
Az.DevTestLabs 1.0.3 PSGallery Microsoft Azure PowerShell - DevTest Labs service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShel…
Az.Dns 1.2.1 PSGallery Microsoft Azure PowerShell - DNS service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core.…
Az.DnsResolver 1.0.0 PSGallery Microsoft Azure PowerShell: DnsResolver cmdlets
Az.ElasticSan 1.1.0 PSGallery Microsoft Azure PowerShell: ElasticSan cmdlets
Az.EventGrid 2.0.0 PSGallery Microsoft Azure PowerShell: EventGrid cmdlets
Az.EventHub 5.0.0 PSGallery Microsoft Azure PowerShell - Event Hubs service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell …
Az.FrontDoor 1.11.1 PSGallery Microsoft Azure PowerShell - Front Door service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell …
Az.Functions 4.1.0 PSGallery Microsoft Azure PowerShell - Azure Functions service cmdlets for Azure Resource Manager in Windows PowerShell and PowerS…
Az.HDInsight 6.2.1 PSGallery Microsoft Azure PowerShell - HDInsight service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell C…
Az.HealthcareApis 2.0.1 PSGallery Microsoft Azure PowerShell: HealthcareApis cmdlets
Az.IotHub 2.7.7 PSGallery Microsoft Azure PowerShell - IoT Hub service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Cor…
Az.KeyVault 6.2.0 PSGallery Microsoft Azure PowerShell - Key Vault service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell C…
Az.Kusto 2.3.1 PSGallery Microsoft Azure PowerShell: Kusto cmdlets
Az.LoadTesting 1.0.1 PSGallery Microsoft Azure PowerShell: LoadTesting cmdlets
Az.LogicApp 1.5.1 PSGallery Microsoft Azure PowerShell - Logic Apps cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core.…
Az.MachineLearning 1.1.4 PSGallery Microsoft Azure PowerShell - Machine Learning Web Services cmdlets for Azure Resource Manager in Windows PowerShell and …
Az.MachineLearningServices 1.1.0 PSGallery Microsoft Azure PowerShell: MachineLearningServices cmdlets
Az.Maintenance 1.4.3 PSGallery Microsoft Azure PowerShell - Maintenance cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core.…
Az.ManagedServiceIdentity 1.2.1 PSGallery Microsoft Azure PowerShell: ManagedServiceIdentity cmdlets
Az.ManagedServices 3.0.1 PSGallery Microsoft Azure PowerShell: ManagedServices cmdlets
Az.MarketplaceOrdering 2.0.1 PSGallery Microsoft Azure PowerShell: MarketplaceOrdering cmdlets
Az.Media 1.1.2 PSGallery Microsoft Azure PowerShell - Media service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core.…
Az.Migrate 2.4.0 PSGallery Microsoft Azure PowerShell: Migrate cmdlets
Az.Monitor 5.2.2 PSGallery Microsoft Azure PowerShell - Monitor service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Cor…
Az.MySql 1.2.1 PSGallery Microsoft Azure PowerShell: MySql cmdlets
Az.Network 7.9.0 PSGallery Microsoft Azure PowerShell - Networking service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell …
Az.NetworkCloud 1.0.2 PSGallery Microsoft Azure PowerShell: NetworkCloud cmdlets
Az.Nginx 1.1.0 PSGallery Microsoft Azure PowerShell: Nginx cmdlets
Az.NotificationHubs 1.1.3 PSGallery Microsoft Azure PowerShell - Notification Hubs cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell C…
Az.OperationalInsights 3.2.1 PSGallery Microsoft Azure PowerShell - Operational Insights service cmdlets for Azure Resource Manager in Windows PowerShell and P…
Az.Oracle 1.0.0 PSGallery Microsoft Azure PowerShell: {ModuleNamePlaceHolder} cmdlets
Az.PolicyInsights 1.6.5 PSGallery Microsoft Azure PowerShell - Azure Policy Insights cmdlets for Windows PowerShell and PowerShell Core. Allows querying p…
Az.PostgreSql 1.1.2 PSGallery Microsoft Azure PowerShell: PostgreSql cmdlets
Az.PowerBIEmbedded 2.0.0 PSGallery Microsoft Azure PowerShell - Power BI Embedded service management cmdlets for Azure Resource Manager in Windows PowerShe…
Az.PrivateDns 1.0.5 PSGallery Microsoft Azure PowerShell - Private DNS service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell…
Az.RecoveryServices 7.2.0 PSGallery Microsoft Azure PowerShell - Recovery Services cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell C…
Az.RedisCache 1.10.0 PSGallery Microsoft Azure PowerShell - Redis Cache service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell…
Az.RedisEnterpriseCache 1.2.1 PSGallery Microsoft Azure PowerShell: RedisEnterpriseCache cmdlets
Az.Relay 2.0.1 PSGallery Microsoft Azure PowerShell: Relay cmdlets
Az.ResourceGraph 1.0.0 PSGallery Microsoft Azure PowerShell - Azure Resource Graph cmdlets in Windows PowerShell and PowerShell Core. Allows querying res…
Az.ResourceMover 1.2.1 PSGallery Microsoft Azure PowerShell: ResourceMover cmdlets
Az.Resources 7.5.0 PSGallery Microsoft Azure PowerShell - Azure Resource Manager and Active Directory cmdlets in Windows PowerShell and PowerShell Co…
Az.Security 1.7.0 PSGallery Microsoft Azure PowerShell - Azure Security Center cmdlets in Windows PowerShell and PowerShell Core. Allows managing an…
Az.SecurityInsights 3.1.2 PSGallery Microsoft Azure PowerShell: SecurityInsights cmdlets
Az.ServiceBus 4.0.0 PSGallery Microsoft Azure PowerShell - Service Bus service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell…
Az.ServiceFabric 3.3.4 PSGallery Microsoft Azure PowerShell - Service Fabric cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core…
Az.SignalR 2.0.2 PSGallery Microsoft Azure PowerShell - Azure SignalR service commands for Windows PowerShell and PowerShell Core.…
Az.Sql 5.3.0 PSGallery Microsoft Azure PowerShell - SQL service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core.…
Az.SqlVirtualMachine 2.3.1 PSGallery Microsoft Azure PowerShell: SqlVirtualMachine cmdlets
Az.StackHCI 2.4.0 PSGallery Microsoft Azure PowerShell: StackHci cmdlets
Az.StackHCIVM 1.0.5 PSGallery Microsoft Azure PowerShell: StackHCIVM cmdlets
Az.Storage 7.4.0 PSGallery Microsoft Azure PowerShell - Storage service data plane and management cmdlets for Azure Resource Manager in Windows Pow…
Az.StorageMover 1.4.0 PSGallery Microsoft Azure PowerShell: StorageMover cmdlets
Az.StorageSync 2.3.1 PSGallery Microsoft Azure PowerShell - Storage Sync cmdlets in Windows PowerShell and PowerShell Core. Manages operations pertaini…
Az.StreamAnalytics 2.0.1 PSGallery Microsoft Azure PowerShell: StreamAnalytics cmdlets
Az.Support 2.0.0 PSGallery Microsoft Azure PowerShell - Azure Support cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core.
Az.Synapse 3.0.10 PSGallery Microsoft Azure PowerShell - Azure Synapse Analytics in Windows PowerShell and PowerShell Core.…
Az.TrafficManager 1.2.2 PSGallery Microsoft Azure PowerShell - Traffic Manager service cmdlets for Azure Resource Manager in Windows PowerShell and PowerS…
Az.Websites 3.2.2 PSGallery Microsoft Azure PowerShell - App Service (Web Apps) service cmdlets for Azure Resource Manager in Windows PowerShell and…
PS >
While Install-PSResource just uses (Find-PSResource -Name 'Az').Dependencies.
All Az submodules that has minimum version of Az.Accounts as a dependency:
Expand
PS > $FindWithDependencies = [array](Find-PSResource -Repository 'PSGallery' -Name 'Az' -IncludeDependencies)
PS > $FindWithDependencies.Where{
$_.'Name' -ne 'Az.Accounts' -and
$(
[System.Version](
$_.'Dependencies'.Where{
$_.'Name' -eq 'Az.Accounts'
}.'VersionRange'.'MinVersion'.'Version'
)
) -lt $([System.Version]('3.0.4'))
}.ForEach{
$Dependency = $_.'Dependencies'.Where{$_.'Name' -eq 'Az.Accounts'}
[PSCustomObject]@{
'Name' = [string] $_.'Name'
'Version' = [string] $_.'Version'
'Az.Accounts-MinVersion' = [string] $Dependency.'VersionRange'.'MinVersion'.'Version'
'Az.Accounts-VersionRange' = [string] $Dependency.'VersionRange'.'OriginalString'
}
} | Format-Table -AutoSize
Name Version Az.Accounts-MinVersion Az.Accounts-VersionRange
---- ------- ---------------------- ------------------------
Az.Advisor 2.0.1 2.19.0.0 [2.19.0, )
Az.AnalysisServices 1.1.5 3.0.0.0 [3.0.0, )
Az.ApplicationInsights 2.2.5 2.19.0.0 [2.19.0, )
Az.ArcResourceBridge 1.0.1 2.19.0.0 [2.19.0, )
Az.Attestation 2.0.2 2.19.0.0 [2.19.0, )
Az.Automation 1.10.0 2.13.2.0 [2.13.2, )
Az.CloudService 2.0.1 2.19.0.0 [2.19.0, )
Az.CognitiveServices 1.14.1 2.13.2.0 [2.13.2, )
Az.ConfidentialLedger 1.0.1 2.19.0.0 [2.19.0, )
Az.ContainerRegistry 4.2.1 2.19.0.0 [2.19.0, )
Az.DataBoxEdge 1.1.1 3.0.0.0 [3.0.0, )
Az.DataLakeAnalytics 1.0.3 2.13.0.0 [2.13.0, )
Az.DataLakeStore 1.3.2 3.0.1.0 [3.0.1, )
Az.DataProtection 2.4.0 2.19.0.0 [2.19.0, )
Az.DataShare 1.0.2 3.0.0.0 [3.0.0, )
Az.DesktopVirtualization 4.3.1 2.19.0.0 [2.19.0, )
Az.DevTestLabs 1.0.3 3.0.0.0 [3.0.0, )
Az.Dns 1.2.1 2.19.0.0 [2.19.0, )
Az.DnsResolver 1.0.0 3.0.0.0 [3.0.0, )
Az.EventGrid 2.0.0 3.0.0.0 [3.0.0, )
Az.EventHub 5.0.0 3.0.0.0 [3.0.0, )
Az.FrontDoor 1.11.1 3.0.1.0 [3.0.1, )
Az.Functions 4.1.0 3.0.1.0 [3.0.1, )
Az.HealthcareApis 2.0.1 2.19.0.0 [2.19.0, )
Az.Kusto 2.3.1 2.19.0.0 [2.19.0, )
Az.LoadTesting 1.0.1 2.19.0.0 [2.19.0, )
Az.LogicApp 1.5.1 2.16.0.0 [2.16.0, )
Az.MachineLearning 1.1.4 3.0.0.0 [3.0.0, )
Az.MachineLearningServices 1.1.0 3.0.3.0 [3.0.3, )
Az.ManagedServiceIdentity 1.2.1 2.19.0.0 [2.19.0, )
Az.ManagedServices 3.0.1 2.19.0.0 [2.19.0, )
Az.MarketplaceOrdering 2.0.1 2.19.0.0 [2.19.0, )
Az.Media 1.1.2 2.13.0.0 [2.13.0, )
Az.Migrate 2.4.0 3.0.1.0 [3.0.1, )
Az.Nginx 1.1.0 3.0.3.0 [3.0.3, )
Az.OperationalInsights 3.2.1 3.0.0.0 [3.0.0, )
Az.Oracle 1.0.0 3.0.3.0 [3.0.3, )
Az.PolicyInsights 1.6.5 2.17.0.0 [2.17.0, )
Az.PowerBIEmbedded 2.0.0 2.13.2.0 [2.13.2, )
Az.PrivateDns 1.0.5 3.0.0.0 [3.0.0, )
Az.RedisCache 1.10.0 3.0.3.0 [3.0.3, )
Az.RedisEnterpriseCache 1.2.1 2.19.0.0 [2.19.0, )
Az.Relay 2.0.1 2.19.0.0 [2.19.0, )
Az.ResourceGraph 1.0.0 3.0.0.0 [3.0.0, )
Az.ResourceMover 1.2.1 2.19.0.0 [2.19.0, )
Az.SecurityInsights 3.1.2 2.19.0.0 [2.19.0, )
Az.ServiceBus 4.0.0 3.0.0.0 [3.0.0, )
Az.StackHCI 2.4.0 3.0.3.0 [3.0.3, )
Az.StorageMover 1.4.0 3.0.1.0 [3.0.1, )
Az.StreamAnalytics 2.0.1 2.19.0.0 [2.19.0, )
Az.Support 2.0.0 3.0.0.0 [3.0.0, )
Az.TrafficManager 1.2.2 2.13.2.0 [2.13.2, )
PS >
None of these specify a maximum version in the version range. So PSResourceGet should not return all those Az.Accounts when Find-PSResource -Repository 'PSGallery' -Name 'Az' -IncludeDependencies?
Summary:
| Command | Count |
|---|---|
(Find-PSResource -Repository 'PSGallery' -Name 'Az' -IncludeDependencies).Count |
99 |
(Find-PSResource -Repository 'PSGallery' -Name 'Az').Dependencies.Count + 1 |
91 |