aws / aws-tools-for-powershell

The AWS Tools for PowerShell lets developers and administrators manage their AWS services from the PowerShell scripting environment.
Apache License 2.0
241 stars 79 forks source link

AWS.Tools.Installer Get-AvailableModuleVersion Find-Module $findModuleParams positional parameter #74

Closed tlindsay42 closed 4 years ago

tlindsay42 commented 4 years ago

Expected Behavior

When multiple module versions are detected in the Get-AvailableModuleVersion private function of the AWS.Tools.Installer module, Find-Module is called again without the MaximumVersion parameter, but it should use a splat for expanding the $findModuleParams hash table instead of passing it as a positional parameter.

Current Behavior

When multiple module versions are detected in the Get-AvailableModuleVersion private function of the AWS.Tools.Installer module, Find-Module is called again without the MaximumVersion parameter on Line 250, but it passes the $findModuleParams hash table as a positional parameter (which is not acceptable for the cmdlet), instead of as a splat like on Line 237.

Possible Solution

250s/\$findModuleParams/@findModuleParams/

Steps to Reproduce (for bugs)

PS C:\> Install-AWSToolsModule -Name 'AWS.Tools.*'
ForEach-Object : A positional parameter cannot be found that accepts argument 'System.Collections.Hashtable'.
At ~\Documents\PowerShell\Modules\AWS.Tools.Installer\1.0.0.0\AWS.Tools.Installer.psm1:250 char:37
+ ... s = $Name | ForEach-Object { Find-Module -Name $_ $findModuleParams @ ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : InvalidArgument: (:) [ForEach-Object], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.ForEachObjectCommand

Context

Causes an unexpected error when attempting to use a wildcard. Wildcards are not supported yet, but discovered this bug while working on a PR for #72 #73.

Your Environment

Include as many relevant details about the environment where the bug was discovered.