DSC icon indicating copy to clipboard operation
DSC copied to clipboard

Ability to transistion from PowerShell script-based to class-based DSC resource

Open Gijsreyn opened this issue 7 months ago • 1 comments

Summary of the new feature / enhancement

As a resource author, I want the ability to transition between script-based to class-based DSC resources without losing backwards compatibility. The Microsoft.Windows/WindowsPowerShell should support both. However, the class-based is never hit in the adapter script because Get-DscResource from PSDesiredStateConfiguration v1.1 never implemented it.

This was tested with the Microsoft.Dotnet.Dsc module and SqlServerDSC. See image below:

Image

[!NOTE] The Microsoft.Dotnet.Dsc module has been modified to target 5.1 in the .psd1 file.

Looking directly in the source code of PSDesiredStateConfiguration, it reveals the following:

Image

Proposed technical implementation details (optional)

Instead of modifying the PSDesiredStateConfiguration, we can implement a small workaround to instantiate a class. If the class can be instantiated, we know it is a class-based DSC resource.

Gijsreyn avatar May 09 '25 08:05 Gijsreyn

We saw this problem when trying to get a class-based resource to run with DSCv3 in the DSC Community module SqlServerDsc. @Gijsreyn was very kind to debug the problem and I hope there is a way forward for this issue so the community can continue converting MOF-based to class-based resources.

johlju avatar May 09 '25 13:05 johlju