PowerShell_Scripts/base/Get-MyModules.ps1

22 lines
709 B
PowerShell

param([switch]$IgnoreSystem,[switch]$MissingOnly)
$local:currentSys = @('Always') + ([SystemName]::_GetValidValues('',$true,$true));
[MyConfig]::GetConfigPaths('mymodules',$false) |
ForEach-Object {
$local:modules = $( Get-Content $_ | ConvertFrom-Json );
$modules |
Get-Member -MemberType NoteProperty | Select-Object -ExpandProperty Name |
Where-Object {
$IgnoreSystem -or ( $_ -in $currentSys )
} |
ForEach-Object { $modules."$_" }
} |
Where-Object {
-not $MissingOnly -or
$( try {
-not (Get-Module -ListAvailable $_ -ErrorAction stop)
} catch { $true }
)
}