Remove-OldModuleVersions
Remove-OldModuleVersions removes stale module folders while keeping the most recent releases.
Syntax
Remove-OldModuleVersions -Name <String> [-Keep <Int>] [-WhatIf] [-Confirm]
Example
# Keep the latest version and preview the removal
Remove-OldModuleVersions -Name 'PSAppDeployToolkit' -Keep 1 -WhatIf
Notes:
- Supports modules installed via PSResourceGet, PowerShellGet, and unmanaged folders.
- Respects
-WhatIf/-Confirmfor safe dry runs. - Works well after
Update-Modulesto clean up superseded copies.