Skip to content

PSResourceList Get returns _exist: true when resource is installed in AllUsers but default is CurrentUser #2005

Description

@Gijsreyn

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest released version
  • Search the existing issues.

Steps to reproduce

As a user, I want _exist to accurately reflect whether a PSResource exists in the requested scope, so that DSC correctly reports and enforces the desired state when scope matters.

The current behavior looks like when a resource entry specifies no scope, ConvertInputToPSResource silently defaults it to CurrentUser. However, GetPSResourceList fetches resources from both scopes and matches on name + version only, totally ignoring the scope. This means when we run, for example, the following document:

resources:
- name: PSResourceList scope test
  type: Microsoft.PowerShell.PSResourceGet/PSResourceList
  properties:
    repositoryName: PSGallery
    resources:
    - name: Pester
      version: '5.7.1'

And Pester is installed in AllUsers scope, it returns:

{ "name": "Pester", "version": "5.7.1", "scope": "AllUsers", "_exist": true }

But the effective desired state has scope: CurrentUser. The resource reports _exist: true with the wrong scope, and a subsequent set will correctly detect a mismatch and reinstall — but the get output is misleading, and _inDesiredState disagreement is confusing.

Expected behavior

`_exist` should reflect whether an instance matching the effective desired scope exists.

Actual behavior

See above JSON snippet

Error details

Environment data

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Binary     1.3.0      preview1   Microsoft.PowerShell.PSResourceGet  Core,Desk {Compress-PSResource, Find-PSResource, …

Key   : PSVersion
Value : 7.6.2
Name  : PSVersion


Key   : PSEdition
Value : Core
Name  : PSEdition


Key   : GitCommitId
Value : 7.6.2
Name  : GitCommitId


Key   : OS
Value : Microsoft Windows 10.0.26100
Name  : OS


Key   : Platform
Value : Win32NT
Name  : Platform


Key   : PSCompatibleVersions
Value : {1.0, 2.0, 3.0, 4.0…}
Name  : PSCompatibleVersions


Key   : PSRemotingProtocolVersion
Value : 2.4
Name  : PSRemotingProtocolVersion


Key   : SerializationVersion
Value : 1.1.0.1
Name  : SerializationVersion


Key   : WSManStackVersion
Value : 3.0
Name  : WSManStackVersion

Visuals

No response

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions