Modify Setup, Path, added Get-MyModules

+ base/Get-MyModules added
* base/profile.d/Test-MyModules modified to use Get-MyModules
* Setup-Profile modified so that sudo witll preserve environment
* Get-Path fixed bug introduced in last commit, Get-Path would fail when
  file to be edited didn't exist
This commit is contained in:
lksz 2021-02-19 19:22:46 -05:00
parent 5dae2a2af5
commit 6d2a23ae04
4 changed files with 41 additions and 25 deletions

21
base/Get-MyModules.ps1 Normal file
View file

@ -0,0 +1,21 @@
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 }
)
}