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