PowerShell / PSDesiredStateConfiguration

Source for https://www.powershellgallery.com/packages/PSDesiredStateConfiguration module
MIT License
56 stars 14 forks source link

Enable `export` for class-based resources #123

Open SteveL-MSFT opened 7 months ago

SteveL-MSFT commented 7 months ago

Summary of the new feature / enhancement

Enable class-based resources to participate in DSCv3 export capability

Proposed technical implementation details (optional)

No response

michaeltlombardi commented 4 months ago

The PowerShell adapter for DSCv3 is implemented to support export for PSDSC Resources when the resource has a static Export method that takes no parameters and returns an array of the PSDSC Resource class.

https://github.com/PowerShell/DSC/blob/0157276b2ada32da5859ce930f4cae2e592f586c/powershell-adapter/psDscAdapter/psDscAdapter.psm1#L296-L301

Following is an example signature for the Export method, using MyDscResource as the class name:

static [MyDscResource[]] Export() {
    # Code to return the array of all instances for the resource
}

However, the PSDesiredStateConfiguration module doesn't know about or handle the Export method at all.