Install Powershell Module from Github Repository

Hi there!

The latest years Powershell started expansion to other platforms and now works on Windows, Linux, and MacOS (I even managed to start it on raspberry Pi Debian distro).

And nowadays the main way for installing modules is PowerShell Gallery but in some situations, it still convenient to install modules directly from the source (the main reason — the main PowerShell modules repo configured to MyGet or NugetServer).

And it can be painful to install Module from GitHub — you should download archive, find modules folder extract archive content and then copy module folder to the Powershell Profile directory.

Moreover — people like me don't want to create a separate repository for each module (yes, I like the Release-Flow approach) so download and extract only the modules you are like -it even more difficult.

Of course, there are several scripts ower the internet that aim to download and install the PowerShell module from GitHub but I didn't find any allowing to install Module from any folder of the Repository in Github. It is the way how to appear the project `InstallFromGithub`.

The first time I have used this installer only for my Powershell Modules, but then decided to separate it to allow use in any script of any repository.

Meet the 'install.ps1' script!

For example, let's try to install Bookmarks module from PowershellScripts repo directly from the GitHub account:

We just need to set parameters

$user="stadub";
$repo="PowershellScripts"
$module="Bookmarks"

also, you can leave the $module variable as blank to indicate the module placed in the root folder

So installation string will be:

iex ('$module="Bookmarks";$user="stadub";$repo="PowershellScripts"'+(new-object net.webclient).DownloadString('https://raw.githubusercontent.com/PsModuleInstall/InstallFromGithub/master/install.ps1'))

Now to check if it works lets import GHiPS and EventLogDrive

Import-Module Bookmarks

Simple, right?!

Under the hood, there is a downloader script that works on any platform with progress and installation check so you won't rewrite your existing module.

As I mentioned before the script separated from other modules and to allows any person to use the unified installer.

And if you have any suggestions or bug report you are welcome to create an issue in the repo.

Best wishes and happy coding,
Dima Stadub
Share post
AdBlock has stolen the banner, but banners are not teeth — they will be back

More
Ads

Comments 0

Only users with full accounts can post comments. Log in, please.