Skip to main content

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 / -Confirm for safe dry runs.
  • Works well after Update-Modules to clean up superseded copies.