PowerShell / PowerShell/DSC

DSC config does discovery on every resource instance

Open
#883 10 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Issue-Bug
Dominant language
Rust
Stars
523
Forks
75
Avg merge
3d 16h
Merged PRs (30d)
24

Description

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

dsc config does discovery for each resource instance. This causes dsc runs to be unnecessarily long. The appx-discover.ps1 script takes on average ~4 seconds.

Why does DSC not do discovery for all resource types at the beginning of a run instead of foreach resource instance?

Steps to reproduce
  1. Create a PowerShell resource instances
  2. dsc config get
Expected behavior

Removed appx and speed improved by ~35 seconds for 7 PowerShell resources.

metadata:
  Microsoft.DSC:
    version: 3.1.0
    operation: get
    executionType: actual
    startDatetime: 2025-06-11T14:03:52.458297900-05:00
    endDatetime: 2025-06-11T14:04:13.214544700-05:00
    duration: PT20.7562468S
    securityContext: restricted
Config is ran without extra time being devoted to multiple resource discoveries.
Actual behavior
metadata:
  Microsoft.DSC:
    version: 3.1.0
    operation: get
    executionType: actual
    startDatetime: 2025-06-11T14:02:26.864581200-05:00
    endDatetime: 2025-06-11T14:03:22.309614-05:00
    duration: PT55.4450328S
    securityContext: restricted
2025-06-11T19:03:16.270404Z TRACE dsc_lib::discovery::command_discovery: 242: Found resource manifest: C:\dsc\assertion.dsc.resource.json
2025-06-11T19:03:16.284597Z TRACE dsc_lib::discovery::command_discovery: 284: Resource 'Microsoft.DSC/Assertion' found
2025-06-11T19:03:16.285374Z TRACE dsc_lib::discovery::command_discovery: 242: Found resource manifest: C:\dsc\echo.dsc.resource.json
2025-06-11T19:03:16.297578Z TRACE dsc_lib::discovery::command_discovery: 284: Resource 'Microsoft.DSC.Debug/Echo' found
2025-06-11T19:03:16.298195Z TRACE dsc_lib::discovery::command_discovery: 242: Found resource manifest: C:\dsc\group.dsc.resource.json
2025-06-11T19:03:16.305508Z TRACE dsc_lib::discovery::command_discovery: 284: Resource 'Microsoft.DSC/Group' found
2025-06-11T19:03:16.306295Z TRACE dsc_lib::discovery::command_discovery: 242: Found resource manifest: C:\dsc\include.dsc.resource.json
2025-06-11T19:03:16.315133Z TRACE dsc_lib::discovery::command_discovery: 284: Resource 'Microsoft.DSC/Include' found
2025-06-11T19:03:16.315906Z TRACE dsc_lib::discovery::command_discovery: 242: Found resource manifest: C:\dsc\osinfo.dsc.resource.json
2025-06-11T19:03:16.324911Z TRACE dsc_lib::discovery::command_discovery: 284: Resource 'Microsoft/OSInfo' found
2025-06-11T19:03:16.325860Z TRACE dsc_lib::discovery::command_discovery: 242: Found resource manifest: C:\dsc\powershell.dsc.resource.json
2025-06-11T19:03:16.328407Z TRACE dsc_lib::discovery::command_discovery: 281: Resource adapter 'Microsoft.DSC/PowerShell' found
2025-06-11T19:03:16.329218Z TRACE dsc_lib::discovery::command_discovery: 242: Found resource manifest: C:\dsc\reboot_pending.dsc.resource.json
2025-06-11T19:03:16.330882Z TRACE dsc_lib::discovery::command_discovery: 284: Resource 'Microsoft.Windows/RebootPending' found
2025-06-11T19:03:16.331393Z TRACE dsc_lib::discovery::command_discovery: 242: Found resource manifest: C:\dsc\registry.dsc.resource.json
2025-06-11T19:03:16.346360Z TRACE dsc_lib::discovery::command_discovery: 284: Resource 'Microsoft.Windows/Registry' found
2025-06-11T19:03:16.346899Z TRACE dsc_lib::discovery::command_discovery: 242: Found resource manifest: C:\dsc\RunCommandOnSet.dsc.resource.json
2025-06-11T19:03:16.351945Z TRACE dsc_lib::discovery::command_discovery: 284: Resource 'Microsoft.DSC.Transitional/RunCommandOnSet' found
2025-06-11T19:03:16.353172Z TRACE dsc_lib::discovery::command_discovery: 242: Found resource manifest: C:\dsc\windowspowershell.dsc.resource.json
2025-06-11T19:03:16.358613Z TRACE dsc_lib::discovery::command_discovery: 281: Resource adapter 'Microsoft.Windows/WindowsPowerShell' found
2025-06-11T19:03:16.359387Z TRACE dsc_lib::discovery::command_discovery: 242: Found resource manifest: C:\dsc\wmi.dsc.resource.json
2025-06-11T19:03:16.361539Z TRACE dsc_lib::discovery::command_discovery: 281: Resource adapter 'Microsoft.Windows/WMI' found
2025-06-11T19:03:16.362928Z DEBUG dsc_lib::discovery::command_discovery: 305: Calling extension 'Microsoft.Windows.Appx/Discover' to discover resources
2025-06-11T19:03:16.364114Z DEBUG dsc_lib::dscresources::command_resource: 699: Invoking command 'powershell' with args Some(["-NoLogo", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-NoProfile", "-Command", "./appx-discover.ps1"])
2025-06-11T19:03:20.284642Z DEBUG dsc_lib::dscresources::command_resource: 660: Process 'powershell' id 19236 exited with code 0
2025-06-11T19:03:20.288204Z  INFO dsc_lib::extensions::dscextension: 99: No results returned for discovery extension 'Microsoft.Windows.Appx/Discover'
2025-06-11T19:03:20.289070Z DEBUG dsc_lib::discovery::command_discovery: 307: Extension 'Microsoft.Windows.Appx/Discover' found 0 resources
2025-06-11T19:03:20.290259Z DEBUG dsc_lib::discovery::command_discovery: 500: Found 0 matching non-adapter-based resources
Error details

Environment data
7.6-preview6
Version

3.1.-rc1

Visuals

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with dsc config get and the dsc_lib::discovery::command_discovery trace, then inspect how the appx-discover.ps1 extension is invoked for each resource instance. Confirm discovery is performed once per resource type during a run, and compare the resulting behavior and timing with the reported 7-resource case.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell, rust
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.