Install-Module needs better parity with Get-Module
In order to provide a consistent interface to scripters using Get-Module and Import-Module, the Install-Module command should accept similar values as Get-Module.
Since Get-Module can only accept module version requirements using the FullyQualifiedModule parameter (which takes a ModuleSpecification[] or a hash table which can cast to one) it would be handy if Install-Module could accept the same object.
Ideally, Install-Module should have a [ModuleSpecification[]]$FullyQualifiedName parameter.
Failing that, Install-Module needs to add a ModuleName alias to it's Name parameter so that we could splat the hashtables, like this:
param(
[Alias("Name")][string]$ModuleName,
[Version]$Version
)
$module = [hashtable]$PSBoundParameter
if (-not (Get-Module -FullyQualifiedName $Module -ListAvailable)) {
Install-Module @Module # this doesn't currently work
}
Import-Module -FullyQualifiedName $Module
This is related to PowerShell/PowerShellGetv2#212. I think the request should be expanded to include PowerShellGet *-Module and Find-* commands.
I'll see about getting this request implemented this week.
Get-PSResource and `Install-PSResource both have a -Version parameter, does that satifsy your use case @Jaykul?
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.
The point isn't to make it compatible with Get-PSResource but with Get-Module (and Import-Module).
If I want to check if the latest PSReadLine module is available, I need to run something like this:
$PSReadLine = @{ ModuleName = "PSReadLine"; ModuleVersion = "2.1.1" }
Get-Module -FullyQualifiedName $PSReadLine
But if I don't find it, and I need to install it, I have to totally refactor my object...
Basically, the problem is that there's no consistency between how I use resources and how I install them! The commands in this module don't have any parameter compatibility with the built-in *-Module commands...