Skip to content

Add support for adapted resource manifests for PowerShell 7 adapter#1415

Open
SteveL-MSFT wants to merge 8 commits intoPowerShell:mainfrom
SteveL-MSFT:ps-adapted-manifest
Open

Add support for adapted resource manifests for PowerShell 7 adapter#1415
SteveL-MSFT wants to merge 8 commits intoPowerShell:mainfrom
SteveL-MSFT:ps-adapted-manifest

Conversation

@SteveL-MSFT
Copy link
Member

@SteveL-MSFT SteveL-MSFT commented Mar 4, 2026

PR Summary

Add support for PowerShell 7 adapted resource manifests.
Note that WindowsPowerShell isn't supported because it relies on PSDSC module using Get-DscResource which only supports finding resources installed for the system.

Also some general fixes found during debugging where splitting $env:PSModulePath could have empty segments which broke the code since it was now passing $null to a cmdlet.

To keep the existing code working, the main change in the adapter is when resourcePath is supplied to import that module and then subsequent code that creates internal structure with the DSC resource tries to use the loaded module first before falling back to existing discovery code. This also means that for an adapted resource manifest, it entirely skips the legacy discovery path so it's much faster.

While testing the change, I noticed that currently there is no way to pass the resource version if specified to the adapter in single mode, created #1414 to handle later, but not blocking.

PR Context

Fix #1412

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds adapted resource manifest support for the PowerShell 7 adapter by allowing the engine to pass a resourcePath into the adapter, importing the module directly, and short-circuiting legacy discovery for faster adapted-manifest operations. This also wires resourcePathArg through the adapter manifests and adds test resources + Pester coverage for the new behavior (including the WinPS “not supported” path).

Changes:

  • Add -ResourcePath handling to the PowerShell adapter entrypoint and pass it through adapter manifests.
  • Enhance module/resource discovery to consider already-imported modules and add a fast-path cache refresh for imported DSC modules.
  • Add adapted-manifest test resources and Pester tests to validate list/get behavior and WinPS unsupported behavior.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
adapters/powershell/psDscAdapter/psDscAdapter.psm1 Adds imported-module inclusion in discovery and a fast-path in Invoke-DscCacheRefresh; adjusts module import usage for type lookup.
adapters/powershell/psDscAdapter/powershell.resource.ps1 Adds ResourcePath parameter, imports the specified module for adapted manifests, and throws on WinPS.
adapters/powershell/PowerShell_adapter.dsc.resource.json Adds resourcePathArg wiring for get/set/test/export operations.
adapters/powershell/WindowsPowerShell_adapter.dsc.resource.json Adds resourcePathArg wiring so WinPS adapter can detect adapted manifests and throw.
adapters/powershell/Tests/PSAdaptedTestClassResource.psm1 New class-based DSC test resources for adapted manifests.
adapters/powershell/Tests/PSAdaptedTestClassResource.psd1 New test module manifest exporting DSC resources and capabilities.
adapters/powershell/Tests/PSAdaptedTestClassResource.dsc.adaptedResource.json New adapted resource manifest for PS7 adapter scenario.
adapters/powershell/Tests/WinPSAdaptedTestClassResource.dsc.adaptedResource.json New adapted resource manifest targeting WinPS adapter (unsupported).
adapters/powershell/Tests/PSAdapted.tests.ps1 New Pester tests validating adapted-manifest discovery and operations.
adapters/powershell/Tests/.project.data.json Ensures test artifacts are copied into the test environment.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

SteveL-MSFT and others added 2 commits March 3, 2026 16:19
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@SteveL-MSFT SteveL-MSFT marked this pull request as draft March 4, 2026 00:41
@SteveL-MSFT SteveL-MSFT marked this pull request as ready for review March 4, 2026 23:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add adapted manifest support for PSAdapter

2 participants