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

Don't accept -Version if string array was supplied to -Name in Install-PSResource and Save-PSResource #1751

Open
3 tasks done
o-l-a-v opened this issue Nov 13, 2024 · 3 comments
Labels
Issue-Discussion Place for discussion about issue/feature/etc

Comments

@o-l-a-v
Copy link
Contributor

o-l-a-v commented Nov 13, 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

With Microsoft.PowerShell.PSResourceGet v1.0.6 you can supply -Version when supplying multiple resources with -Name.

That does not make much sense and should error instead of event trying, in my opinion.

Example command:

Install-PSresource -Repository 'PSGallery' -TrustRepository -Scope 'CurrentUser' `
    -Name 'Az.Accounts', 'Microsoft.Graph.Authentication' -Version '3.0.5' -Verbose

Expected behavior

ERROR: -Version can only be supplied if -Name is a single value.

Actual behavior

PS > Install-PSresource -Repository 'PSGallery' -TrustRepository -Scope 'CurrentUser' -Name 'Az.Accounts', 'Microsoft.Graph.Authentication' -Version '3.0.5' -Verbose

VERBOSE: All paths to search: 'C:\Users\olav.birkeland\<redacted>\Documents\PowerShell\Modules'
VERBOSE: All paths to search: 'C:\Users\olav.birkeland\<redacted>\Documents\PowerShell\Scripts'
VERBOSE: Retrieving directories in the path 'C:\Users\olav.birkeland\<redacted>\Documents\PowerShell\Modules'
VERBOSE: Retrieving directories in the path 'C:\Users\olav.birkeland\<redacted>\Documents\PowerShell\Scripts'
VERBOSE: All paths to search: 'C:\Users\olav.birkeland\<redacted>\Documents\PowerShell\Modules\Microsoft.PowerToys.Configure'
VERBOSE: The PSGetModuleInfo.xml file found at location: C:\Users\olav.birkeland\<redacted>\Documents\PowerShell\Modules\Microsoft.PowerToys.Configure\0.86.0.0\PSGetModuleInfo.xml cannot be parsed due to TryReadPSGetInfo: Cannot read the PSResourceGet information file with error: Could not find file 'C:\Users\olav.birkeland\<redacted>\Documents\PowerShell\Modules\Microsoft.PowerToys.Configure\0.86.0.0\PSGetModuleInfo.xml'.
VERBOSE: Attempting to search for packages in 'PSGallery'
VERBOSE: Performing the operation "Install-PSResource" on target "Package to install: 'Az.Accounts', version: '3.0.5'".
VERBOSE: Performing the operation "Install-PSResource" on target "Exit ShouldProcess".
VERBOSE: Installation source path is: 'C:\Users\olav.birkeland\AppData\Local\Temp\a9dc49c9-a34a-4630-b611-f7c93885c5f4\az.accounts\3.0.5'
VERBOSE: Installation destination path is: 'C:\Users\olav.birkeland\<redacted>\Documents\PowerShell\Modules\Az.Accounts\3.0.5'
VERBOSE: Attempting to move 'C:\Users\olav.birkeland\AppData\Local\Temp\a9dc49c9-a34a-4630-b611-f7c93885c5f4\az.accounts\3.0.5' to 'C:\Users\olav.birkeland\<redacted>\Documents\PowerShell\Modules\Az.Accounts\3.0.5'
VERBOSE: Successfully installed package 'Az.Accounts' to location 'C:\Users\olav.birkeland\<redacted>\Documents\PowerShell\Modules'
VERBOSE: Attempting to delete 'C:\Users\olav.birkeland\AppData\Local\Temp\a9dc49c9-a34a-4630-b611-f7c93885c5f4'
VERBOSE: Successfully deleted 'C:\Users\olav.birkeland\AppData\Local\Temp\a9dc49c9-a34a-4630-b611-f7c93885c5f4'
VERBOSE: Package with name 'Microsoft.Graph.Authentication', version '3.0.5' could not be found in repository 'PSGallery'.
VERBOSE: Attempting to delete 'C:\Users\olav.birkeland\AppData\Local\Temp\3b2ac088-6a76-4541-85bb-0501bd87b2c1'
VERBOSE: Successfully deleted 'C:\Users\olav.birkeland\AppData\Local\Temp\3b2ac088-6a76-4541-85bb-0501bd87b2c1'
Install-PSResource: Package(s) 'Microsoft.Graph.Authentication' could not be installed from repository 'PSGallery'.

PS >

Error details

No response

Environment data

  • Windows 11 24H2
  • PowerShell x64 v7.4.6
  • Microsoft.PowerShell.PSResourceGet v1.0.6

Visuals

No response

@SydneyhSmith
Copy link
Collaborator

We are wondering about a use case where you want multiple packages of the same version (like multiple Az packages)

@SydneyhSmith SydneyhSmith added Issue-Discussion Place for discussion about issue/feature/etc and removed Needs-Triage labels Nov 13, 2024
@ThomasNieto
Copy link
Contributor

This behavior is useful for a collection of modules that all share the same release version. Like the Az module mentioned above or when PSRG supports NuGet that would be a common use case.

@o-l-a-v
Copy link
Contributor Author

o-l-a-v commented Nov 20, 2024

I obviously don't agree this is a nice feature since I created this issue. I believe this functionality can cause more confusion than being helpful.

Az modules often don't have the same version. Here are the latest version of Az.* modules, filtering away anything older than published the last 180 days.

Find-PSResource -Repository 'PSGallery' -Name 'Az', 'Az.*' |
  Where-Object -FilterScript {
    $_.'Author' -eq 'Microsoft Corporation' -and
    $_.'PublishedDate' -gt [datetime]::Now.AddDays(-180)
  } |
  Sort-Object -Property 'Name' |
  Select-Object -Property 'Name', 'Version', 'PublishedDate' |
  New-MDTable |
  Set-Clipboard
Name Version PublishedDate
Az 13.0.0 19.11.2024 05:15:55
Az.Accounts 4.0.0 19.11.2024 05:04:35
Az.ADDomainServices 0.2.2 03.09.2024 01:02:58
Az.Aks 6.0.4 03.09.2024 01:03:03
Az.AksArc 0.1.2 11.11.2024 06:37:11
Az.AnalysisServices 1.1.6 11.11.2024 04:39:58
Az.ApiManagement 4.0.5 11.11.2024 04:40:01
Az.App 2.0.0 19.11.2024 05:05:24
Az.AppComplianceAutomation 0.1.2 11.11.2024 06:37:28
Az.AppConfiguration 1.3.2 03.09.2024 01:03:23
Az.ArcGateway 0.1.0 11.11.2024 06:37:36
Az.Astro 0.1.1 19.11.2024 05:05:42
Az.Attestation 2.0.3 11.11.2024 04:40:15
Az.Automanage 1.0.2 03.09.2024 01:03:34
Az.Batch 3.6.4 11.11.2024 04:40:23
Az.Billing 2.1.0 08.10.2024 07:39:58
Az.Blueprint 0.4.4 08.10.2024 07:40:08
Az.Cdn 3.2.2 03.09.2024 01:03:51
Az.CodeSigning 0.2.0 06.08.2024 01:17:12
Az.Communication 0.4.1 11.11.2024 06:38:24
Az.Compute 9.0.0 19.11.2024 05:06:40
Az.Computer 1.0.3 11.10.2024 20:46:32
Az.ConnectedKubernetes 0.13.0 15.11.2024 04:12:23
Az.ConnectedMachine 1.1.0 19.11.2024 05:06:59
Az.ContainerInstance 4.1.0 19.11.2024 05:07:07
Az.CosmosDB 1.15.0 08.10.2024 07:41:04
Az.CostManagement 0.3.3 08.10.2024 07:41:08
Az.DataBox 0.3.2 03.09.2024 01:04:34
Az.Databricks 1.9.0 03.09.2024 01:04:38
Az.DataFactory 1.18.9 11.11.2024 04:41:01
Az.DataLakeStore 1.3.2 09.07.2024 01:48:51
Az.DataMigration 0.14.8 08.10.2024 07:41:47
Az.DataProtection 2.5.0 11.11.2024 04:41:08
Az.DesktopVirtualization 5.4.0 19.11.2024 05:08:07
Az.DevCenter 2.0.0 19.11.2024 05:08:19
Az.DeviceProvisioningServices 0.10.3 11.11.2024 06:39:38
Az.Dns 1.3.0 19.11.2024 05:08:45
Az.DnsResolver 1.1.0 19.11.2024 05:08:50
Az.Elastic 0.2.0 11.11.2024 06:40:05
Az.ElasticSan 1.2.0 19.11.2024 05:09:01
Az.EventGrid 2.1.0 11.11.2024 04:41:30
Az.EventHub 5.0.1 11.11.2024 04:41:33
Az.Fabric 0.1.0 08.10.2024 07:42:48
Az.FrontDoor 1.11.1 09.07.2024 01:49:59
Az.Functions 4.1.1 11.11.2024 04:41:40
Az.HanaOnAzure 0.3.2 03.09.2024 01:05:43
Az.HDInsight 6.3.0 19.11.2024 05:09:44
Az.HdInsightOnAks 0.2.0 06.08.2024 01:19:51
Az.HealthDataAIServices 0.1.0 11.11.2024 06:40:52
Az.Informatica 0.1.0 06.08.2024 01:20:07
Az.IotCentral 0.10.2 08.10.2024 07:43:37
Az.IotHub 2.7.7 03.09.2024 01:06:02
Az.KeyVault 6.3.0 19.11.2024 05:10:31
Az.KubernetesRuntime 0.1.0 08.10.2024 07:43:51
Az.MachineLearningServices 1.1.0 06.08.2024 01:20:46
Az.Maintenance 1.4.3 03.09.2024 01:06:23
Az.ManagementPartner 0.7.4 08.10.2024 07:44:25
Az.Marketplace 0.5.1 08.10.2024 07:44:34
Az.Mdp 0.1.0 19.11.2024 05:11:19
Az.Migrate 2.5.0 11.11.2024 04:42:23
Az.Monitor 6.0.0 19.11.2024 05:11:48
Az.MySql 1.2.1 03.09.2024 01:06:58
Az.NeonPostgres 0.1.0 19.11.2024 05:11:56
Az.NetAppFiles 0.20.0 19.11.2024 05:12:01
Az.Network 7.11.0 19.11.2024 05:12:09
Az.NetworkCloud 1.0.2 03.09.2024 01:07:09
Az.NewRelic 0.2.0 09.07.2024 01:52:07
Az.Nginx 1.1.0 06.08.2024 01:21:58
Az.NotificationHubs 1.1.3 03.09.2024 01:07:18
Az.Oracle 1.0.0 22.08.2024 04:03:45
Az.PaloAltoNetworks 0.3.0 09.07.2024 01:52:19
Az.PostgreSql 1.1.2 03.09.2024 01:07:38
Az.PrivateDns 1.1.0 11.11.2024 04:42:57
Az.Qumulo 0.1.2 03.09.2024 01:07:51
Az.RecoveryServices 7.3.0 19.11.2024 05:13:21
Az.RedisCache 1.10.0 06.08.2024 01:22:54
Az.RedisEnterpriseCache 1.4.0 21.10.2024 06:32:03
Az.ResourceGraph 1.0.1 11.11.2024 04:43:09
Az.Resources 7.7.0 19.11.2024 05:13:58
Az.Security 1.7.0 03.09.2024 01:08:20
Az.ServiceBus 4.0.1 11.11.2024 04:43:27
Az.ServiceFabric 3.3.4 03.09.2024 01:08:30
Az.ServiceLinker 0.2.2 11.11.2024 06:44:24
Az.SignalR 2.0.2 03.09.2024 01:08:34
Az.Sphere 0.1.2 03.09.2024 01:08:36
Az.Sql 6.0.0 19.11.2024 05:14:43
Az.SqlVirtualMachine 2.3.1 03.09.2024 01:08:43
Az.StackHCI 2.4.1 15.10.2024 13:06:05
Az.StackHCIVM 1.0.5 08.10.2024 07:47:17
Az.StandbyPool 0.2.0 08.10.2024 07:47:20
Az.Storage 8.0.0 19.11.2024 05:04:55
Az.StorageMover 1.4.0 09.07.2024 01:54:02
Az.StorageSync 2.3.1 03.09.2024 01:09:00
Az.Synapse 3.0.10 03.09.2024 01:09:10
Az.Terraform 0.1.1 11.11.2024 06:45:13
Az.TimeSeriesInsights 0.2.2 03.09.2024 01:09:13
Az.VMware 0.7.1 03.09.2024 01:09:17
Az.Websites 3.2.2 08.10.2024 07:48:35
Az.Workloads 0.3.0 10.09.2024 01:28:27

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Discussion Place for discussion about issue/feature/etc
Projects
None yet
Development

No branches or pull requests

3 participants