Skip to content

(dsc): Add _purge to PSResourceList resource #2052

Description

@Gijsreyn

Summary of the new feature / enhancement

As a user, I want _purge: true on a PSResourceList instance so that any resource installed from that repository and not present in resources is uninstalled during set, and reported as a difference during test.

resources:
- name: Only these modules
  type: Microsoft.PowerShell.PSResourceGet/PSResourceList
  properties:
    repositoryName: PSGallery
    _purge: true
    resources:
    - name: Pester
    - name: PSScriptAnalyzer

With Pester, PSScriptAnalyzer and Az.Accounts installed from PSGallery, test reports _inDesiredState: false and set uninstalls Az.Accounts.

Proposed technical implementation details (optional)

  • Add _purge to the PSResourceList schema, referencing the DSC purge.json property schema.
  • In GetPSResourceListActions, when _purge is set, append an Uninstall action for every installed resource from the repository that has no matching desired entry. test, set and what-if pick this up automatically since they share that function.
  • Respect scope: only purge from the scopes the listed resources use, or from both when none is specified, and document which one was chosen.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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