Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
# 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
# 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