PowerShell Gallery Metapackages

Recently, I was approached by supa-famous Joey Aiello of the PowerShell team at my favorite conference ever, PSConf.eu.

So Joey comes up and says "Chrissy, Aaron Nelson has pretty much required me to talk to you. The SQL Community has the #1 PowerShell UserVoice request. We see that - we've heard you, The People want Out-DataTable and we agree. Would you be happy if we added it to the PowerShell Gallery first?"

"Uh, no! I want Out-DataTable to be a first class citizen like Out-GridView."

"But where we're going with PowerShell -- we're going smaller - to just core files, then you add on from the Gallery as desired."

"Oh dang, like Linux! I'm liking it, keep talking."

"To be clear, this is post 6.0. In the 6.0 timeframe, but we want to decouple as many release trains as possible, like PowerShellGet and PSReadline. But we'll still very well package the 'uber-complete, awesome devops tool edition' of PowerShell. In the meantime, you could setup a metapackage for just your database stuff."

"So it is like Linux patterns! PowerShell Gallery does that? I'm sold."

Why I'm really happy with this answer

I've used Linux for a really long time and appreciate how you install your core files, then pile other stuff on as needed. In SUSE Linux's Package Manager (and maybe others) these are called patterns.

So for me when setting up my Linux servers, I skip on the GUI patterns and select, for instance, a LAMP pattern. That has all the stuff I need like Apache, PHP, Python, MySQL, etc -- but nothing more.

If you take a closer look at the screenshot above, you'll see some sample patterns include

  • Console Tools
  • Laptop
  • Software Management
  • X Windows System

If you check the Console Tools, you'll find a number of packages that make it easier to work with the console including alpine, nano and ncftp.

So about Metapackages

PowerShell is similar in this way now that you can create a PowerShell Gallery module that's made solely of other modules or packages. Recently, I created a metapackage named Database. Currently, this metapackage contains

In the future, I'll be able to add Out-Datatable (or whatever they name it, perhaps ConvertTo-DataTable) and then any other database related module that makes sense. If you have any suggestions, let me know.

Here's how I did it (copy/paste/change guid)

First, you must ensure that you've installed the modules that you want to require. Initially, I got an error when trying to Publish-Module and because I needed to install the DSC resource, xSqlServer, prior to attempting to include it in the metapackage.

Next, create new directory that's the same name as your module, then add a psd1 to that directory. That's all you need. Just one module manifest (.psd1) in one folder. So for the Database module, mine was C:\github\Database\database.psd1.

This is what the actual psd1 looks like - note that the important line is:

RequiredModules = @('sqlserver','dbatools','dbareports','PowerUpSQL','xsqlserver')

If you'd like to create your own metapackage, you can copy/paste and then change the GUID and info. To get a new GUID, just use New-Guid or [guid]::NewGuid() to generate your own unique GUID.


Publishing your metapackage to the PowerShell Gallery is like publishing any other PowerShell module. First, you sign up to the PowerShell Gallery, then get your NuGetApiKey key, then... Actually, just follow this tutorial by Adam Bertram :).

I stored my database.psd1 in C:\github\Database, so I published it by executing

Publish-Module -NuGetApiKey xyz-xyz-xyz-xyz-xyz -Path C:\github\Database


Once your module has been published to the Gallery, it can be installed like any other module from the Gallery.

My own package contains the SqlServer module which has a naming issue on some machines, so if you'd like to install the Database metapackage, just throw in -AllowClobber at the end.

Install-Module database -AllowClobber

Check out how cool this is -- it automatically downloads all the required modules :D Nice work, PowerShell Team!

Hope that's been helpful. If you have any questions about metapackages, hit up me or Joey on Twitter (and follow him while you're at it. He needs a couple followers ;)