Repository navigation
Uninstall OldModuleVersion
Removes older versions of modules, keeping only the newest.
Uninstall-OldModuleVersion [[-Name] <String[]>] [-Keep <Int32>] [-Scope <String[]>] [-Force] [-PassThru]
[-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]
Updating a module installs the new version alongside the old one, so versions build up over time. This removes all but the newest -Keep versions of each module.
Versions that ship with PowerShell or Windows are never removed. Versions loaded in the current session, and old versions that another installed module depends on, are kept unless -Force is used. For example, each Az rollup version pins exact versions of the Az.* modules, so those are kept while that Az version is installed. Prompts for confirmation by default.
Uninstall-OldModuleVersion -WhatIf
Previews which old versions would be removed.
Uninstall-OldModuleVersion Pester -Keep 2 -Confirm:$false
Keeps the two newest versions of Pester and removes the rest, without prompting.
One or more module names. Wildcards are supported. Defaults to all modules.
Type: String[]
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: *
Accept pipeline input: True (ByPropertyName, ByValue)
Accept wildcard characters: TrueHow many of the newest versions to keep. Defaults to 1.
Type: Int32
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: 1
Accept pipeline input: False
Accept wildcard characters: FalseOnly remove versions installed in these scopes. All scopes are still counted when working out which versions are newest.
Type: String[]
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseRemove versions even if they are loaded in the current session, or other installed modules depend on them.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalseOutput an object for each version that was removed.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalseShows what would happen if the cmdlet runs. The cmdlet is not run.
Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalsePrompts you for confirmation before running the cmdlet.
Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False{{Fill ProgressAction Description}}
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseThis cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).