PowerShellGet – Package Management for PowerShell modules – Part 2


In previous post, we discussed PowerShellGet versus PackageManagement/OneGet.
Now that we have a better understanding of what PowerShellGet is all about, let’s have a look at the cmdlets in the PowerShellGet module. 

Using the PowerShellGet module, you can:

 

image
PowerShellGet allows unified management of PowerShell modules, scripts and DSC resources.

 

Find cmdlets (Module, Script, DSCResource)

The find cmdlets search online through items (module, script, DSC resource) in an online gallery. By default, that is the PowerShell Gallery.
These items include:

  • Module
  • Script
  • DSC Resource

Install cmdlets (Module, Script)

The install cmdlets download one or more items from an online gallery and installs them on the local computer. By default, that is the PowerShell Gallery.
These items include:

  • Module
  • Script

The install cmdlets (Install-Script, Install-Module) operate against the default PS repository, but are configurable through the Register-PSRepository, Set-PSRepository, Unregister-PSRepository and Get-PSRepository cmdlets.
When operating against multiple repositories, Install-Script installs the first script that matches the specified search criteria (Name, MinimumVersion, or MaximumVersion) from the first repository without any error.

By default, these installed items live in “C:\Program Files\WindowsPowerShell”.

image

Save cmdlets (Module, Script)

The save cmdlets download one or more items from an online gallery without installing them on the local computer. By default, that is the PowerShell Gallery.
These items include:

  • Module
  • Script

Get cmdlets (InstalledModule, InstalledScript)

The get cmdlets retrieve a list of the installed items (by PowerShellGet Install-Module, Install-Script ) on the local computer.
These items include:

  • Installed Module
  • Installed Script

For module items, this information is retrieved from the file “PSGetModuleInfo.xml” in each module folder.
For script items, this information is retrieved from the file “<script>_InstalledScriptInfo.xml”.

image
The overview of installed modules as a result of using the Install-Module cmdlet.

Update cmdlets (Module, Script)

The update cmdlets download and install the newest version of specified modules from an online gallery to the local computer. By default, that is the PowerShell Gallery.
These items include:

  • Module
  • Script

Uninstall cmdlets (Module, Script)

The uninstall cmdlets uninstall items on the local computer.
These items include:

  • Module
  • Script

Publish cmdlets (Module, Script)

The publish cmdlets publish specified items from the local computer to an online gallery. By default, that is the PowerShell Gallery.
These items include:

  • Module
  • Script

Publishing a module and/or script requires metadata that is displayed on the gallery page for the module.
The required metadata includes the module name, version, description and author.
Although most metadata is taken from the module manifest, some metadata must be specified in Publish-Module parameters, such as Tag, ReleaseNote, IconUri, ProjectUri and LicenseUri.

We will cover publishing scripts and module to the PowerShell Gallery in another blog post.

PowerShell Repository cmdlets

The PSRepository cmdlets provide management of the PowerShell repositories.
These repositories may be public or private, accessible via the internet or only accessible on an internal network.

These cmdlets include:

  • Get-PSRepository
  • Set-PSRepository
  • Register-PSRepository
  • Unregister-PSRepository

image

Each registered repository is associated with a package provider, which is specified in the “PackageManagementProvider property.
Each provider is designed to interact with a specific type of repository. For example, the NuGet provider is designed to interact with NuGet-based repositories.

Each registered repository has an installation policy and specifies PowerShell behavior when installing items from that repository.
When installing items (modules/script) from an Untrusted repository, the user is prompted for confirmation.

Each registered repository has a URI for discovering and installing modules from this repository.
For example, for NuGet-based repositories, the source location is similar to http://someNuGetUrl.com/api/v2/.

image

 

NOTE: PowerShellGet also contains other cmdlets relating to

  • Creating/updating script file info (with metadata required for publishing script files to the gallery)
  • Updating module manifest .pds1 files (with metadata required for publishing modules to the gallery)
  • Related reading:

  • TechNet Library – PowerShellGet Module cmdlets
  • MDSN Library – JEA (Just Enough Admin) 
  • One thought on “PowerShellGet – Package Management for PowerShell modules – Part 2

    Leave a comment