When multiple versions are found for the specified modules, the minimum version is selected, and then another series of Find-Module is run to query the PowerShell Gallery for each specified module, which is unnecessary and slow.
Motivation and Context
Improves performance by pruning slow & unnecessary code.
Resolves #83
Testing
Imported working version and re-ran Install-AWSToolsModule -Name '*' (unsupported, but effective for demonstrating the test). Arrives at the confirmation prompt much faster that specifies the version to install.
Example 1
C:\> Install-AWSToolsModule -Name AWS.Tools.* -Verbose
VERBOSE: [Install-AWSToolsModule] ConfirmPreference=High WhatIfPreference=False VerbosePreference=Continue Force=False
VERBOSE: [Get-AvailableModuleVersion] ConfirmPreference=High WhatIfPreference=False VerbosePreference=Continue Force=False
VERBOSE: [Get-AvailableModuleVersion] Found multiple modules versions: 1.0.0.1, 4.0.1.0, 4.0.1.1.)
VERBOSE: [Get-AvailableModuleVersion] End
VERBOSE: [Install-AWSToolsModule] Installing AWS Tools version 1.0.0.1
VERBOSE: [Install-AWSToolsModule] Searching installed modules
VERBOSE: Populating RepositorySourceLocation property for module AWS.Tools.APIGateway.
VERBOSE: Populating RepositorySourceLocation property for module AWS.Tools.ApiGatewayV2.
VERBOSE: Populating RepositorySourceLocation property for module AWS.Tools.Common.
VERBOSE: Populating RepositorySourceLocation property for module AWS.Tools.Common.
VERBOSE: Populating RepositorySourceLocation property for module AWS.Tools.EC2.
VERBOSE: Populating RepositorySourceLocation property for module AWS.Tools.EC2.
VERBOSE: Populating RepositorySourceLocation property for module AWS.Tools.ECR.
VERBOSE: Populating RepositorySourceLocation property for module AWS.Tools.Installer.
VERBOSE: [Install-AWSToolsModule] Merging existing modules into the list of modules to install
VERBOSE: Populating RepositorySourceLocation property for module AWS.Tools.APIGateway.
VERBOSE: Populating RepositorySourceLocation property for module AWS.Tools.ApiGatewayV2.
VERBOSE: Populating RepositorySourceLocation property for module AWS.Tools.Common.
VERBOSE: Populating RepositorySourceLocation property for module AWS.Tools.Common.
VERBOSE: Populating RepositorySourceLocation property for module AWS.Tools.EC2.
VERBOSE: Populating RepositorySourceLocation property for module AWS.Tools.EC2.
VERBOSE: Populating RepositorySourceLocation property for module AWS.Tools.ECR.
VERBOSE: Populating RepositorySourceLocation property for module AWS.Tools.Installer.
VERBOSE: Populating RepositorySourceLocation property for module AWS.Tools.APIGateway.
VERBOSE: Populating RepositorySourceLocation property for module AWS.Tools.ApiGatewayV2.
VERBOSE: Populating RepositorySourceLocation property for module AWS.Tools.Common.
VERBOSE: Populating RepositorySourceLocation property for module AWS.Tools.Common.
VERBOSE: Populating RepositorySourceLocation property for module AWS.Tools.EC2.
VERBOSE: Populating RepositorySourceLocation property for module AWS.Tools.EC2.
VERBOSE: Populating RepositorySourceLocation property for module AWS.Tools.ECR.
Confirm
Are you sure you want to perform this action?
Performing the operation "Install-AWSToolsModule" on target "AWS Tools version 1.0.0.1".
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"):
VERBOSE: [Install-AWSToolsModule] Create folder for temporary repository ~\AppData\Local\Temp\jopffh3j.u2v
VERBOSE: [Install-AWSToolsModule] Registering temporary repository AWSToolsTemp
VERBOSE: [Install-AWSToolsModule] Downloading modules to temporary repository
VERBOSE: Populating RepositorySourceLocation property for module AWS.Tools.APIGateway.
VERBOSE: [Save-AWSToolsModule] ConfirmPreference=None WhatIfPreference=False VerbosePreference=Continue Force=False
VERBOSE: [Install-AWSToolsModule] Unregistering temporary repository AWSToolsTemp
VERBOSE: [Install-AWSToolsModule] Delete repository folder ~\AppData\Local\Temp\jopffh3j.u2v
PackageManagement\Find-Package : No match was found for the specified search criteria and module name 'AWS.Tools.APIGateway'. Try Get-PSRepository to see all available registered module repositories.
At ~\Documents\PowerShell\Modules\PowerShellGet\2.2.1\PSModule.psm1:8871 char:9
+ PackageManagement\Find-Package @PSBoundParameters | Microsoft ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Microsoft.PowerShel\u2026Cmdlets.FindPackage:FindPackage) [Find-Package], Exception
+ FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.FindPackage
Example 2
~> Install-AWSToolsModule -Name AWS.Tools.* -Verbose -RequiredVersion '4.0.1.1'
VERBOSE: [Install-AWSToolsModule] ConfirmPreference=High WhatIfPreference=False VerbosePreference=Continue Force=False
VERBOSE: [Install-AWSToolsModule] Searching installed modules
VERBOSE: Populating RepositorySourceLocation property for module AWS.Tools.APIGateway.
VERBOSE: Populating RepositorySourceLocation property for module AWS.Tools.ApiGatewayV2.
VERBOSE: Populating RepositorySourceLocation property for module AWS.Tools.Common.
VERBOSE: Populating RepositorySourceLocation property for module AWS.Tools.Common.
VERBOSE: Populating RepositorySourceLocation property for module AWS.Tools.EC2.
VERBOSE: Populating RepositorySourceLocation property for module AWS.Tools.EC2.
VERBOSE: Populating RepositorySourceLocation property for module AWS.Tools.ECR.
VERBOSE: Populating RepositorySourceLocation property for module AWS.Tools.Installer.
VERBOSE: [Install-AWSToolsModule] Merging existing modules into the list of modules to install
VERBOSE: Populating RepositorySourceLocation property for module AWS.Tools.APIGateway.
VERBOSE: Populating RepositorySourceLocation property for module AWS.Tools.ApiGatewayV2.
VERBOSE: Populating RepositorySourceLocation property for module AWS.Tools.Common.
VERBOSE: Populating RepositorySourceLocation property for module AWS.Tools.Common.
VERBOSE: Populating RepositorySourceLocation property for module AWS.Tools.EC2.
VERBOSE: Populating RepositorySourceLocation property for module AWS.Tools.EC2.
VERBOSE: Populating RepositorySourceLocation property for module AWS.Tools.ECR.
VERBOSE: Populating RepositorySourceLocation property for module AWS.Tools.Installer.
VERBOSE: Populating RepositorySourceLocation property for module AWS.Tools.APIGateway.
VERBOSE: Populating RepositorySourceLocation property for module AWS.Tools.ApiGatewayV2.
VERBOSE: Populating RepositorySourceLocation property for module AWS.Tools.Common.
VERBOSE: Populating RepositorySourceLocation property for module AWS.Tools.Common.
VERBOSE: Populating RepositorySourceLocation property for module AWS.Tools.EC2.
VERBOSE: Populating RepositorySourceLocation property for module AWS.Tools.EC2.
VERBOSE: Populating RepositorySourceLocation property for module AWS.Tools.ECR.
Confirm
Are you sure you want to perform this action?
Performing the operation "Install-AWSToolsModule" on target "AWS Tools version 4.0.1.1".
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"):
VERBOSE: [Install-AWSToolsModule] Create folder for temporary repository ~\AppData\Local\Temp\rvr2aclh.uhb
VERBOSE: [Install-AWSToolsModule] Registering temporary repository AWSToolsTemp
VERBOSE: [Install-AWSToolsModule] Downloading modules to temporary repository
VERBOSE: Populating RepositorySourceLocation property for module AWS.Tools.APIGateway.
VERBOSE: Populating RepositorySourceLocation property for module AWS.Tools.ApiGatewayV2.
VERBOSE: Populating RepositorySourceLocation property for module AWS.Tools.Common.
VERBOSE: Populating RepositorySourceLocation property for module AWS.Tools.Common.
VERBOSE: Populating RepositorySourceLocation property for module AWS.Tools.EC2.
VERBOSE: Populating RepositorySourceLocation property for module AWS.Tools.EC2.
VERBOSE: Populating RepositorySourceLocation property for module AWS.Tools.ECR.
VERBOSE: Populating RepositorySourceLocation property for module AWS.Tools.Installer.
VERBOSE: [Save-AWSToolsModule] ConfirmPreference=None WhatIfPreference=False VerbosePreference=Continue Force=False
VERBOSE: [Install-AWSToolsModule] Unregistering temporary repository AWSToolsTemp
VERBOSE: [Install-AWSToolsModule] Delete repository folder ~\AppData\Local\Temp\rvr2aclh.uhb
Find-Module : The RequiredVersion, MinimumVersion, MaximumVersion, AllVersions or AllowPrerelease parameters are allowed only when you specify a single name as the value of the Name parameter, without any wildcard characters.
At ~\git\aws-tools-for-powershell\modules\installer\AWS.Tools.Installer.psm1:313 char:27
+ $moduleInfo = Find-Module @findModuleParams @proxyParams
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Find-Module], ArgumentException
+ FullyQualifiedErrorId : VersionParametersAreAllowedOnlyWithSingleName,Find-Module
Types of changes
[ ] Bug fix (non-breaking change which fixes an issue)
[x] New feature (non-breaking change which adds functionality)
[ ] Breaking change (fix or feature that would cause existing functionality to change)
Checklist
[x] My code follows the code style of this project
[ ] My change requires a change to the documentation
[ ] I have updated the documentation accordingly
[x] I have read the README document
[ ] I have added tests to cover my changes
[x] All new and existing tests passed
License
[x] I confirm that this pull request can be released under the Apache 2 license
This looks fine to me. I have to run tests on the module in the next few days, so I will run it through some tests to be extra sure.
Thanks for the PR.
Description
When multiple versions are found for the specified modules, the minimum version is selected, and then another series of
Find-Module
is run to query the PowerShell Gallery for each specified module, which is unnecessary and slow.Motivation and Context
Improves performance by pruning slow & unnecessary code. Resolves #83
Testing
Imported working version and re-ran
Install-AWSToolsModule -Name '*'
(unsupported, but effective for demonstrating the test). Arrives at the confirmation prompt much faster that specifies the version to install.Example 1
Example 2
Types of changes
Checklist
License