Neat Project to Install PowerShell Modules from GitHub Projects

While I do love the PowerShell Gallery for hosting PowerShell Modules, there’s a lot of content sitting on GitHub, too. Especially for code versions that haven’t yet made it all the way through a major or minor build and released to the Gallery. Doug Finke has crafted a handy module to assuage some of the friction in easily pulling code down from GitHub, regardless of what has been published to the Gallery. Check out the InstallModuleFromGitHub project and Doug’s writeup!

It’s fairly simple. Either use the PowerShell Gallery to install the module, or download the module and place it into your PowerShell Modules folder (I prefer to use my OneDrive location to sync across devices). From there you can start grabbing code from GitHub.

If the user has published their project onto the PowerShell Gallery – along with a valid GitHub URL – you’ll be able to snag the code using the familiar Find-Module cmdlet. You can find the ProjectUri property in the module manifest. A highlighted example is below:

# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
PrivateData = @{
    PSData = @{
        # Tags applied to this module. These help with module discovery in online galleries.
        Tags = 'Rubrik','Converged_Data_Management','CDM','Backup','Recovery','Data_Protection'
        # A URL to the license for this module.
        LicenseUri = 'https://github.com/rubrikinc/PowerShell-Module/blob/master/LICENSE'
        # A URL to the main website for this project.
        ProjectUri = 'https://github.com/rubrikinc/PowerShell-Module'

To grab the code, use the Find-Module cmdlet and pipe it to the Install-ModuleFromGitHub function. This will lookup the Project URI and snag the bits.

github-install-find-module

If there is no Project URI setting, nag the author and then grab the bits directly from GitHub. This is also handy for grabbing something other than the master branch by using the -Branch parameter.

github-install-find-module-no-gallery

Big thanks to Doug! I’ve enjoyed using this to grab pull requests and non-master branches for the various GitHub projects for which I’m involved.