-
Notifications
You must be signed in to change notification settings - Fork 50
Experimental PowerShell discover extension #1071
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
With PR #1025 around, it might be worthwhile to rename the directories. |
623d593
to
5b7502f
Compare
5b7502f
to
991f7ce
Compare
…jsreyn/operation-methods into implement-powershell-discover
6337045
to
f15195a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few questions and requests:
- 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
orpwsh
. - Can we slightly restructure this script to define (currently empty)
param
block and put the implementation into theprocess
block? That can help with organization and testing later on. - 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.
|
…jsreyn/operation-methods into implement-powershell-discover
param () | ||
|
||
begin { | ||
$psPaths = $env:PSModulePath -split [System.IO.Path]::PathSeparator | Where-Object { $_ -notmatch 'WindowsPowerShell' } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we throwing away paths with WindowsPowerShell
in them for performance reasons or because we don't want to support discovering resources shipped in Windows PowerShell modules?
If the latter, I think we might be better off retrieving the folder paths for discovered modules and searching those.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quite honestly, the only reason that I'm filtering it out is because if I can remember correctly, there was a bug in the past where we filtered out WindowsPowerShell
in the adapter (or tests). Looking through the codebase, I can see this was the change: https://github.com/PowerShell/DSC/pull/777/files
If we opt for searching folder paths, I suppose it needs to match the specific operating systems, which becomes a ugly if/elseif/else
block. It also limits custom installation, which will be lost. For example:

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
Note
While I recognize the need for caching in the issue, I left it out for now, assuming we can increment it over time.