ps/Modules/Cole.PowerShell.Developer/Public/Clear-AlkamiModules.ps1

36 lines
1008 B
PowerShell
Raw Permalink Normal View History

2023-05-30 22:51:22 -07:00
function Clear-AlkamiModules {
<#
.SYNOPSIS
Use this to unload all the Alkami modules and non-module script files
#>
[CmdletBinding()]
[OutputType([void])]
param (
)
function Select-ModulesForDevelopmentUnloading {
<#
.SYNOPSIS
Filter the module list passed in to return modules to remove based on script-only or alkami name matching
#>
param(
[Parameter(Position=0,Mandatory=$true,ValueFromPipeline=$true)]
$Module = @()
)
process {
if ($Module.Name -match 'Alkami') {
return $Module
}
if ($Module.Name -eq 'Cole.PowerShell.Developer') {
return $Module
}
if ($Module.Version -eq '0.0' -and $Module.ModuleType -eq 'script' -and @($Module.ExportedCommands.Keys).length -eq 0) {
return $Module
}
}
}
(Get-Module) | Select-ModulesForDevelopmentUnloading | Remove-Module -Force
}