PowerShell / PSDesiredStateConfiguration

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

Update Invoke-DscClassBasedResource #48

Closed anmenaga closed 3 years ago

anmenaga commented 3 years ago

Old code that was returning just a type from a clean runspace had a problem where local module functions were not visible to class's methods when called. Returning an instance from a new clean runspace has a problem that PS streams (verbose/debug/etc) were not transferred to the calling runspace (a blocker for GC). Per suggestion from Dongbo, changed code to returning an instance but creating it using [PowerShell]::Create('CurrentRunspace'). This also removes a need for an InitialSessionState-hack to transfer parent PSModulePath to a clean runspace.