In the same way that Node.js project developers have a package repository with code snippets such as NPM, and .NET developers have NuGet, PowerShell module and script developers have the PowerShell Gallery, a service managed by Microsoft in which, according to its website,
"You will find useful modules that contain PowerShell commands and Desired State Configuration (DSC) resources. You will also find scripts (some of which may contain PowerShell workflows), which describe a set of tasks and provide sequencing of those tasks. chores".
The PowerShell Gallery currently has 66,367 packages, of which almost 3,200 million downloads have already been made. Some of the packages have been developed by Microsoft itself, but many others are created by the PowerShell community itself.
To get an idea of the type of utilities it offers, between the most popular packages of the repository, the following stand out:
Az.Accounts: Module with 'cmdlets' to manage user accounts in Azure Resource Manager.
PackageManagement: A package manager for accessing software over the Internet.
Computer ManagementDsc: DSC resources related to computer administration aspects such as task scheduling, virtual memory or power configuration management, etc.
Despite being focused mainly on the Windows world, PowerShell and its gallery can also be used on Linux.
A basic look at how to use it
Thanks to the PowerShellGet module, any PowerShell user can use the gallery to upload, detect and download all kinds of packages. Before updating it, we must install the most recent version of the aforementioned NuGet, using the following command:
Install-PackageProvider -Name NuGet -Force
Otherwise, when we try to use it, PowerShell will offer to install it. This is what happens if we try to do a search for Active Directory related modules in the gallery (using the command
'Find-Module *activedirectory*') without having previously installed it:
Once installed, we will be able to carry out the corresponding search:
And when we know which module we want to install on our computer, just run Install-Module. Example:
Install-Module -Name PowerShellGet
If, on the other hand, we want to install a script, we must use the command 'Install-Script', also followed by its name in the PowerShell Gallery.
Of course, as with other similar package managers, modules and scripts can be updated with more modern versions. For this we will have the commands'Update-Module'or'Update-Script'.
And finally, we can perform a check of what we have installed in the past from the PowerShell Gallery, with the commands'Get-InstalledModule' and 'Get-InstalledScript'.