Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uninstall older versions of PowerShell after successful upgrade #130

Open
baziwane opened this issue Sep 24, 2021 · 1 comment
Open

Uninstall older versions of PowerShell after successful upgrade #130

baziwane opened this issue Sep 24, 2021 · 1 comment
Labels
Enhancement An enhancement of already existing feature.

Comments

@baziwane
Copy link
Collaborator

Title: Uninstall older versions of PowerShell after successful upgrade

Description: Should have a way to uninstall older powershell versions after successful upgrade.

@baziwane baziwane added the Enhancement An enhancement of already existing feature. label Sep 24, 2021
@baziwane
Copy link
Collaborator Author

Actively investigating this issue - in the meantime you can use this workaround.

  1. Save the following script as remove_old_modules.ps1 and run it in PowerShell after upgrading your clusters
$modules = @("AksHci", "Kva", "Moc", "DownloadSdk", "TraceProvider")
foreach($module in $modules)
{
    $current = Get-InstalledModule -Name $module -ErrorAction Ignore
    if (-not $current)
    {
        Write-Host $("[Module: $module] Is not installed, skipping")
        continue
    }
    Write-Host $("[Module: $module] Newest installed version is $($current.Version)")
    $versions = Get-InstalledModule -Name $module -AllVersions
    foreach($version in $versions)
    {
        if ($version.Version -eq $current.Version)
        {
            Write-Host $("[Module: $module] Skipping uninstall for version $($version.Version)")
            continue
        }
        Write-Host $("[Module: $module] Uninstalling version $($version.Version)")
        $version | Uninstall-Module -Force -Confirm:$false
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement An enhancement of already existing feature.
Projects
None yet
Development

No branches or pull requests

1 participant