Functions/Uninstall-OldInstalledModules.ps1
function Uninstall-OldInstalledModules { [CmdletBinding()] param ( ) foreach ($m in Get-InstalledModule) { Get-InstalledModule $m.Name -AllVersions | Where-Object { $_.Version -ne $m.Version } | ForEach-Object { Write-Output "Uninstalling module $($_.Name) version $($_.Version)" Uninstall-Module -Name $_.Name -MaximumVersion $_.Version -Force } } } |