PowerShell_Scripts/profile.d/Test-MyModules.ps1

19 lines
545 B
PowerShell

if( -not $global:MyModulesWarning ) {
$global:MyModulesWarning = @()
}
[MyConfig]::GetConfigPaths('mymodules',$false) |
ForEach-Object {
$( Get-Content $_ | ConvertFrom-Json ).Modules
} | Where-Object {
$local:m = $_
if( $( try {
-not (Get-Module -ListAvailable $m -ErrorAction stop)
} catch { $true }
)) {
$m -notin $global:MyModulesWarning
}
} | ForEach-Object {
$global:MyModulesWarning += $_
Write-Warning "Missing module: $_"
}