This repository was archived by the owner on Jun 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 133
Expand file tree
/
Copy pathGet-InstalledModuleDetails.ps1
More file actions
50 lines (42 loc) · 2.35 KB
/
Get-InstalledModuleDetails.ps1
File metadata and controls
50 lines (42 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
function Get-InstalledModuleDetails
{
[CmdletBinding()]
param
(
[Parameter()]
[string]
$Name,
[Parameter()]
[string]
$RequiredVersion,
[Parameter()]
[string]
$MinimumVersion,
[Parameter()]
[string]
$MaximumVersion
)
Set-InstalledModulesVariable
# Keys in $script:PSGetInstalledModules are "<ModuleName><ModuleVersion>",
# first filter the installed modules using "$Name*" wildcard search
# then apply $Name wildcard search to get the module name which meets the specified name with wildcards.
#
$wildcardPattern = New-Object System.Management.Automation.WildcardPattern "$Name*",$script:wildcardOptions
$nameWildcardPattern = New-Object System.Management.Automation.WildcardPattern $Name,$script:wildcardOptions
$script:PSGetInstalledModules.GetEnumerator() | Microsoft.PowerShell.Core\ForEach-Object {
if($wildcardPattern.IsMatch($_.Key))
{
$InstalledModuleDetails = $_.Value
if(-not $Name -or $nameWildcardPattern.IsMatch($InstalledModuleDetails.PSGetItemInfo.Name))
{
if (Test-ItemPrereleaseVersionRequirements -Version $InstalledModuleDetails.PSGetItemInfo.Version `
-RequiredVersion $RequiredVersion `
-MinimumVersion $MinimumVersion `
-MaximumVersion $MaximumVersion)
{
$InstalledModuleDetails
}
}
}
}
}