Skip to content

Commit e944909

Browse files
committed
feat: ✨ Add Get-ModuleExtension function to retrieve module extensions
* Rename existing function * Supports an optional parameter to list all available modules or only the latest version of each module. * Includes detailed documentation and examples for ease of use.
1 parent 1867c28 commit e944909

1 file changed

Lines changed: 27 additions & 4 deletions

File tree

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,29 @@
11
function Get-ModuleExtension {
2+
<#
3+
.SYNOPSIS
4+
Retrieves module extensions based on specified criteria.
5+
6+
.DESCRIPTION
7+
This function retrieves module extensions that match the specified module
8+
name and version criteria.
9+
10+
.PARAMETER ModuleName
11+
The name of the module to retrieve extensions for.
12+
13+
.PARAMETER ModuleVersion
14+
The version of the module to retrieve extensions for.
15+
16+
.PARAMETER ListAvailable
17+
Indicates whether to list all available modules or only the the latest
18+
version of each module.
19+
20+
.EXAMPLE
21+
Get-ModuleExtension -ModuleName "MyModule" -ModuleVersion "1.0.0"
22+
23+
Retrieves extensions for the module "MyModule" with version "1.0.0".
24+
.NOTES
25+
26+
#>
227
[CmdletBinding()]
328
param(
429
[string]
@@ -11,9 +36,9 @@ function Get-ModuleExtension {
1136
$ListAvailable
1237
)
1338

14-
#Only get the latest version of each module
39+
# Only get the latest version of each module
1540
$modules = Get-Module -ListAvailable
16-
if (!$ListAvailable) {
41+
if (!$ListAvailable.IsPresent) {
1742
$modules = $modules |
1843
Group-Object Name |
1944
ForEach-Object {
@@ -25,8 +50,6 @@ function Get-ModuleExtension {
2550

2651
Write-Verbose "Found $($modules.Length) installed modules to scan for extensions."
2752

28-
29-
3053
foreach ($module in $modules) {
3154
if ($module.PrivateData -and
3255
$module.PrivateData.PSData -and

0 commit comments

Comments
 (0)