DSC icon indicating copy to clipboard operation
DSC copied to clipboard

Experimental PowerShell discover extension

Open Gijsreyn opened this issue 4 months ago • 5 comments

PR Summary

Implements an optimized approach to discovering PowerShell resources using .NET with parallel processing and direct result synchronization.

The previous approach using Get-ChildItem had unnecessary object overhead and required post-processing with Where-Object. The same is implied when using a thread-safe collection (ConcurrentBag), which adds unnecessary complexity.

PR Context

Fix #913

Gijsreyn avatar Aug 21 '25 13:08 Gijsreyn

With PR #1025 around, it might be worthwhile to rename the directories.

Gijsreyn avatar Aug 21 '25 13:08 Gijsreyn

A few questions and requests:

  1. Do I correctly understand that this extension only for resources implemented in PowerShell and excluding Windows PowerShell? If so, do we need a second extension for discovering those resources, or can we handle that in this one? I'm not sure I see an immediate reason for why we can't handle both here, given the manifest has to indicate whether the resource is invoked with powershell or pwsh.
  2. Can we slightly restructure this script to define (currently empty) param block and put the implementation into the process block? That can help with organization and testing later on.
  3. The current implementation can't run in Windows PowerShell, I think, given the use of ForEach-Object -Parallel - but we can still discover resources in Windows PowerShell modules.
  1. The one currently written is only compatible with PowerShell 7+ because of the [System.IO.EnumerationOptions]. We might be able to rewrite it, but as you also mentioned (from point 3), the Foreach-Object -Parallel is not implemented. It would be best to create a second extension for it with different logic.
  2. Sure, I'll implement this change. Thanks for the comment!
  3. Answered in point 1.

Gijsreyn avatar Sep 03 '25 17:09 Gijsreyn

The WG discussed this and agree to not have WinPS support initially until there is a customer need

SteveL-MSFT avatar Sep 17 '25 18:09 SteveL-MSFT

@SteveL-MSFT - by any chance, if you have time to review this one, I would appreciate it.

Gijsreyn avatar Sep 22 '25 22:09 Gijsreyn

@SteveL-MSFT - caching added. Took a couple of rounds because of returning nothing. Added this to the docs after discussing with Mikey.

Gijsreyn avatar Oct 08 '25 18:10 Gijsreyn