techfreak.ch Blog

Some stuff for me to remember

Home Blog About me

Uninstall old PowerShell Module Versions

If you’re using a Module like AzureRm, and you update it from time to time (Update-Module), you will find that you’ll have a couple of versions installed of all the individual modules. Something like this:

To get rid of the old versions, you can use this easy script:

It loops through all of the modules, retains the latest version of each module, and uninstalls all of the others. It’s not AzureRm’s fault, it’s the fault of PowerShellGet, with the “Update-Module” functionality not actually being an “Update”, but just a Side-by-Side installation of the new version.