Tools/Clear-BCDevModule.ps1
function Clear-BCDevModule { param ( [Parameter( Mandatory = $false)] $Name ) if ($null -eq $Name) { $Modules = Get-InstalledModule } else { $Modules = Get-InstalledModule $Name } foreach ($Mod in $Modules) { $Latest = Get-InstalledModule $Mod.Name $SpecificMods = Get-InstalledModule $Mod.Name -allversions Write-Verbose "Module $($Mod.Name) found, latestversion $($Latest.Version)" foreach ($SubModule in $SpecificMods) { if ($SubModule.version -ne $Latest.version) { Write-Verbose " Uninstalling $($SubModule.Name) - $($SubModule.Version)" $SubModule | Uninstall-Module -Force } } } } Export-ModuleMember -Function Clear-BCDevModule |