On October 9th, PSResourceGet became Generally Available (GA)! This blog post will show you what it is and how it adds to / replaces the current PowerShellGet v2.2.5.

What is PowerShellGet?

“PowerShellGet is a module with commands for discovering, installing, updating and publishing PowerShell artifacts like Modules, DSC Resources, Role Capabilities, and Scripts.”


What is PSResourceGet?

“PSResourceGet is a complete re-write of PowerShellGet, the package manager for PowerShell, with the following goals:

  • Create a more intuitive package manager: Make PowerShell resource management more intuitive and easier to use by removing unnecessary prompts when possible.
  • Address top customer issues: Many of the top customer issues in previous versions of the module have been challenging to resolve because of architecture decisions made early on in the development of PowerShellGet.
  • Allow for a smooth transition to a better experience: Transitioning from lower versions of PSResourceGet should be as painless as possible. With the help of our compatibility layer explained in more detail below, our goal is to enable users and scripts built on PowerShellGet 2.0 to move seamlessly to the PSResourceGet engine.
  • Improve maintainability of the codebase: This goal is addressed by removing the provider model that PowerShellGet was originally built on.”


How to install

You can install the new module using PowerShellGet (The “classic” Install-Module way) by running:

Install-Module -Name Microsoft.PowerShell.PSResourceGet
Import-Module -Name Microsoft.PowerShell.PSResourceGet

Note: PSResourceGet will be available in the upcoming PowerShell v7.4 by default, which will be available side by side with PowerShellGet v.2.2.5

New cmdlet names

PSResourceGet comes with these cmdlets:

Find-PSResourceSearches for packages from a repository (local or remote), based on a name or other package properties.
Get-InstalledPSResourceReturns modules and scripts installed on the machine via PowerShellGet.
Get-PSResourceRepositoryFinds and returns registered repository information.
Get-PSScriptFileInfoReturns the metadata for a script.
Import-PSGetRepositoryFinds the repositories registered with PowerShellGet and registers them for PSResourceGet.
Install-PSResourceInstalls resources from a registered repository.
New-PSScriptFileInfoThe cmdlet creates a new script file, including metadata about the script.
Publish-PSResourcePublishes a specified module from the local computer to PSResource repository.
Register-PSResourceRepositoryRegisters a repository for PowerShell resources.
Save-PSResourceSaves resources (modules and scripts) from a registered repository onto the machine.
Set-PSResourceRepositorySets information for a registered repository.
Test-PSScriptFileInfoTests the comment-based metadata in a .ps1 file to ensure it’s valid for publication.
Uninstall-PSResourceUninstalls a resource that was installed using PowerShellGet.
Unregister-PSResourceRepositoryRemoves a registered repository from the local machine.
Update-PSModuleManifestUpdates a module manifest file.
Update-PSResourceDownloads and installs the newest version of a package already installed on the local machine.
Update-PSScriptFileInfoThis cmdlet updates the comment-based metadata in an existing script .ps1 file.

Using PSResourceGet

You can use the PSResourceGet cmdlets from the module just like you are used to. Install-Module is now Install-PSResource, and Uninstall-Module is Uninstall-PSResource, etc., you get the idea 😉

When you use Install-PSResource to install a Module, it will ask if you trust the PSGallery repository. For example:

Install-PSResource -Name ImportExcel

Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its Trusted value by running the Set-PSResourceRepository cmdlet. Are you sure you want to install the PSResource from 'PSGallery'?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"): Y

After answering the prompt with Y, the requested Module will be installed. To avoid having to answer this question, you can configure the PSGallery to be a trusted repository by using:

Set-PSResourceRepository -Name PSGallery -Trusted

To uninstall Modules that were installed with Install-PSResouce, you can use Uninstall-PSResource. For example:

Uninstall-PSResource ImportExcel
Uninstalling ImportExcel... [1/1 directory uninstalling...

To reinstall a Module, you can use the -Reinstall parameter. For example:

Install-PSResource ImportExcel
WARNING: Resource 'ImportExcel' with version '7.8.5' is already installed.  If you would like to reinstall, please run the cmdlet again with the -Reinstall parameter
Install-PSResource ImportExcel -Reinstall

To update a Module, you can use the Update-PSResource cmdlet. For example:

Update-PSResource ImportExcel

PowerShellGet v3

You can update your scripts to use the new PSResource cmdlet, but PowerShellGet v3 will make things easier for you:

“If you aren’t ready to update all of your scripts to the new cmdlets (that can be a big task), PowerShellGet, and the existing cmdlet interface, is still there for you to use.

In order to bridge the gap between PowerShellGet v2 (the current latest stable PowerShellGet is 2.2.5), and PSResourceGet we introduce a compatibility layer for PSResourceGet and are shipping it as PowerShellGet v3. This module is currently in a preview state and working towards a GA.

In the latest preview of PowerShellGet (3.0.22-beta22), the PowerShellGet syntax is the same, but it is actually a proxy function for PSResourceGet and uses the new engine. This is to allow users to take advantage of some of the bug fixes/performance improvements without needing to update their scripts, or have scripts unexpectedly break at module or PowerShell update time.

Given these three modules the current recommendation would be to use PSResourceGet for new scripts, or if you want to take advantage of new features and use the newest/most supported version of the module. If you are able to use prerelease versions, or are willing to test out PowerShellGet v3 (the compat layer), we really appreciate all testing for this so we can make changes before this reaches GA. Once PowerShellGet v3 reaches GA, this would be the recommended version for old scripts which you may not want to update, but may want to use a more supported module for (in terms of bug fixes from the team), and thereby take advantage of bug fixes/performance updates. Note that PowerShellGet v3 will be focused on backwards compatibility and not adoption of new features (although there may be incidental new features).

Finally, if everything is working totally great for you on PowerShellGet v2 you are free to continue to use it. Nothing has changed about the extent to which it is supported.

In PowerShell 7.5 expect to see PowerShellGet version incremented to a v3 version.”


Wrapping up

You can start using and testing PSResourceGet as the new way of installing/uninstalling/updating modules, but PowerShellGet v3 will make things easier and compatible with your current scripts. I will be covering that, too, when it becomes Generally Available.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.