Skip to content

Add Unpublish-PSResource command to unlist/hide module versions programmatically #1929

@MariusStorhaug

Description

@MariusStorhaug

Summary of the new feature / enhancement

As a PowerShell user automating module publishing workflows, I want a command to quickly unlist or hide specific versions of a module (such as prereleases after the full version is published), so that I can ensure only relevant versions are visible on the PowerShell Gallery without manual UI steps.

Currently, unlist functionality exists in the PowerShell Gallery UI and is also supported via API key permissions, but there is no native PowerShell command to do this in automation scenarios. This limits streamlined management when transitioning from prerelease to stable versions or when hiding obsolete/pre-release versions is required within CI/CD systems.

Proposed technical implementation details (optional)

Add a new cmdlet named Unpublish-PSResource. It should accept similar parameters as Find-PSResource, with the addition of -ApiKey (similar to Publish-PSResource). This command would use the API key (with appropriate unlist permission) to programmatically unlist or hide the specified package version on the Gallery.

The command should support:

  • Specifying a specific version (including prerelease versions) to unlist
  • Pipeline input from Find-PSResource to unpublish multiple resources at once

Example usage:

Unpublish-PSResource -Repository PSGallery -ApiKey $APIKey -Name $moduleName -Version 2.0.1 -Prerelease

# Unpublish multiple versions via pipeline
Find-PSResource -Name $moduleName -Version "2.0.1" -Prerelease | Unpublish-PSResource -Repository PSGallery -ApiKey $APIKey

This feature would greatly improve automation workflows for module publishers and mirror the manual UI and API support for unlisting that already exists.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions