Last active
December 21, 2018 04:55
-
-
Save rdronov/eb654f151ac640fc386d6237f9ecd015 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# File name: Remove-OldPowerCLI.ps1 | |
# Description: This script removes the old versions of VMware.PowerCLI and its dependencies | |
# | |
# 21/12/2018 - Version 1.0 | |
# - Initial Release (based on https://windowsserver.uservoice.com/forums/301869-powershell/suggestions/14934876-update-module-needs-flag-to-remove-previous-versio) | |
# | |
# Author: Roman Dronov (c) | |
$modules = @((Get-Module -ListAvailable | ? {$_.Name -like "VMware*"}).Name | Get-Unique) | |
foreach ($module in $modules){ | |
$latest = Get-InstalledModule -Name $module | |
Get-InstalledModule -Name $module -AllVersions | ? {$_.Version -ne $latest.Version} | Uninstall-Module -Force -Verbose | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment