Skip to content

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

@o-l-a-v

Description

@o-l-a-v

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-DiscussionPlace for discussion about issue/feature/etc

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions