Skip to content

Instantly share code, notes, and snippets.

@fslef
Created June 6, 2025 09:52
Show Gist options
  • Select an option

  • Save fslef/854430dd087304d13582819cf1a64d48 to your computer and use it in GitHub Desktop.

Select an option

Save fslef/854430dd087304d13582819cf1a64d48 to your computer and use it in GitHub Desktop.
Remove old Powershell Modules
$Latest = Get-InstalledModule
foreach ($module in $Latest) {
Write-Verbose -Message "Uninstalling old versions of $($module.Name) [latest is $( $module.Version)]" -Verbose
Get-InstalledModule -Name $module.Name -AllVersions | Where-Object {$_.Version -ne $module.Version} | Uninstall-Module -Verbose -force
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment