Contents

PowerShell

ModuleFast 1.0 Is Out

During PowerShell's 20th birthday show, Justin Grote casually dropped this in the YouTube chat: "ModuleFast 1.0 is out! Happy bday PowerShell"

I was watching the PowerShell 20th birthday show when that message came by, and sure enough, the 1.0 release had just been published on GitHub. A birthday present for PowerShell, and a good reason to take a proper look at what changed.

ModuleFast is a module installer focused on one thing: getting modules and their dependencies onto your machine as fast as possible. It downloads in parallel, works out the full dependency tree before it starts, and uses Justin’s own PowerShell Gallery mirror (pwsh.gallery) by default. I mentioned it before in my Sampler post, where -UseModuleFast speeds up resolving a module’s dependencies.

It isn’t meant to replace PSResourceGet, the official module manager. PSResourceGet aims for compatibility; ModuleFast trades some of that for speed. The modules it installs are regular modules, so Get-Module, Import-Module and friends work with them as usual.

  • It’s a binary module now. ModuleFast used to be one large PowerShell script. 1.0 is rewritten in C#, which Justin says gives more speed and a better structure for supporting other repository types later.
  • The commands are declared stable. The cmdlets and parameters won’t change without being announced as a breaking change, which makes it a safer choice for build pipelines.
  • A standalone CLI. Next to the module there’s a trimmed executable you can download and run without PowerShell loading a module. On the 1.0 release page that’s a Linux x64 build (modulefast-linux-x64).
PowerShell 7.6 or later only

ModuleFast 1.0 requires PowerShell 7.6+, because it uses newer storage and zip APIs. Version 0.6 keeps working on 7.4 and older (both out of support by now). The release notes say the bootstrap script should pick 0.6 for you there, but the v1.0.0 bootstrap script only falls back to 0.6 when downloading the binary module fails, not based on your PowerShell version. Still on 7.4? Test before you rely on that.

The quickest way in is the bootstrap one-liner, which loads ModuleFast for the current session without installing anything through PowerShellGet first:

$PSVersionTable.PSVersion
iwr bit.ly/modulefast | iex
Get-Module ModuleFast | Select-Object Name, Version | Format-Table -AutoSize
Get-Command -Module ModuleFast | Format-Table Name, CommandType -AutoSize
Major  Minor  Patch  PreReleaseLabel BuildLabel
-----  -----  -----  --------------- ----------
7      7      0

Name       Version
----       -------
ModuleFast 1.0.0

Name                  CommandType
----                  -----------
Clear-ModuleFastCache      Cmdlet
Install-ModuleFast         Cmdlet

Both commands show up as Cmdlet: that’s the new compiled module at work.

Before installing, you can see what it would do. ModuleFast resolves the whole dependency tree up front, so -WhatIf shows the plan, including where each module comes from:

Install-ModuleFast PSWriteHTML, Microsoft.PowerShell.ConsoleGuiTools -WhatIf
What if: Performing the operation "Install 2 Modules" on target "C:\Users\RobertPrüst\AppData\Local\powershell\Modules".

Name                                 ModuleVersion Location
----                                 ------------- --------
Microsoft.PowerShell.ConsoleGuiTools 0.7.7         https://pwsh.gallery/index.json
PSWriteHTML                          1.45.0        https://pwsh.gallery/index.json

It also has a short syntax for version requirements: = for an exact version, >/>=/</<= for ranges, and ! to allow prereleases. And it can read requirements from a file, like this demo.requires.json:

[
  "PSWriteHTML>=1.40.0",
  "Microsoft.PowerShell.ConsoleGuiTools"
]

Run Install-ModuleFast without arguments, and it picks up any *.requires.json (or .psd1) in the current folder. Add -CI to write a lockfile with the exact versions it installed, so a build server gets the same versions next time:

Install-ModuleFast -CI
Get-ChildItem | Format-Table Name, Length -AutoSize
Name               Length
----               ------
demo.requires.json     70
requires.lock.json     83
run-demo.ps1          762

The install itself prints nothing; you just get your prompt back. The lockfile shows what it picked:

{
  "Microsoft.PowerShell.ConsoleGuiTools": "0.7.7",
  "PSWriteHTML": "1.45.0"
}
Silence means nothing to do

When everything you ask for is already installed, ModuleFast says nothing at all. Add -Verbose to see why: 2 Module Specifications have all been satisfied by installed modules. If you would like to check for newer versions remotely, specify -Update.

Pin the version in pipelines

bit.ly/modulefast always points to the latest release. In a pipeline, pin it: & ([scriptblock]::Create((iwr 'bit.ly/modulefast'))) -Release 'v1.0.0' -Specification ImportExcel.

On Windows, ModuleFast installs to LocalAppData\powershell\Modules, which isn’t on PSModulePath by default. According to the README, it offers to add that folder to your profile the first time. Use -Destination if you’d rather install somewhere else.

On the usage side, not much has changed compared to before. The commands and parameters work the way they did, so if you already use ModuleFast, you’ll hardly notice the switch to a binary module. What has changed is that it’s now a proper stable release, and I’m happy it finally got there. Now that it’s officially 1.0, I’ll start moving my own projects over to it.

Congratulations on 1.0, Justin, and nice timing. 🚀