PowerShell: PowerShellGet Helper Functions

With the PowerShell Gallery at your fingertips in PowerShell v5 you are able to find and install modules and scripts quickly. Here are a few helper functions you may want to add to your profile to help automate some of these tasks.

I’ve been using Install-Module, Find-Module, and the other nifty commands in PowerShellGet for a while now. A few tasks which I’ve found helpful have morphed into their own scripts that I run fairly often. These helper functions have been published for a while buried in one of my github repos but I figured they are worthy enough for their own quick post. I keep these in a path of one-off scripts that gets loaded into my user’s environmental path variable within my PowerShell profile.

Helper 1: Upgrade-InstalledModules.ps1

This simple script wraps around the Get-InstalledModule and Update-Module commands and attempts to upgrade modules installed on your system. Nothing fancy here.

Helper 2: Remove-OldModule.ps1

As you begin to use install-module you will start to collect older versions of modules without even realizing it. This helper script will check a module for all the versions that are installed and attempt to remove all but the newest version.  When you run this without any module name it will loop through all installed modules. If you are worried about what it might try to uninstall use the -WhatIf flag.

And that is really it. Enjoy!

Comments (0)

› No comments yet.

Leave a Reply

Follow

Get every new post delivered to your Inbox

Join other followers