Last active
May 22, 2025 01:09
-
-
Save HeyItsGilbert/f3599ed8b52996319e831575decd05af to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param( | |
[int]$Limit | |
) | |
$modules = Get-Module -ListAvailable | |
$finalList = @() | |
$hash = @{ | |
'Errbody' = @() | |
} | |
foreach($module in $modules){ | |
$root, $name = $module.Name -split '[.]' | |
if(-not [String]::IsNullOrEmpty($name)){ | |
if(-not $hash.ContainsKey($root)){ | |
$hash[$root] = @() | |
} | |
$hash[$root] += $module | |
} else { | |
$finalList += $module | |
} | |
$subList = @() | |
$hash.GetEnumerator() | %{ | |
if ($_.Value.Count -ge $Limit){ | |
$finalList += $_.Key | |
} else { | |
# If the count was less then the limit, toss them all back in | |
$finalList += $_.Value | |
} | |
} | |
# Finally print the list | |
$finalList | Sort-Object |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment