Tools/Clear-BCDevModule.ps1
function Clear-BCDevModule { param ( [Parameter( Mandatory = $false)] $Name ) $Modules = Get-InstalledModule $Name foreach ($Mod in $Modules) { $Latest = Get-InstalledModule $Mod.Name $SpecificMods = Get-InstalledModule $Mod.Name -allversions if ($PSBoundParameters.ContainsKey('Verbose')) { Write-Host "Module $($Mod.Name) found, latestversion $($Latest.Version)" -ForegroundColor Green } foreach ($SubModule in $SpecificMods) { if ($SubModule.version -ne $Latest.version) { if ($PSBoundParameters.ContainsKey('Verbose')) { Write-Host " uninstalling $($SubModule.Name) - $($SubModule.Version)" -NoNewline } $SubModule | Uninstall-Module -Force if ($PSBoundParameters.ContainsKey('Verbose')) { Write-Host " ... Done." } } } } } Export-ModuleMember -Function Clear-BCDevModule |