Author Posts

July 18, 2016 at 2:57 pm

OS         : Windows 2012 R2
OS Version : 6.3.9600
PSVersion  : 5.0.10586.117

While working on Class based DSC resource I encountered some issues and inconsistencies I can't explain.
I've created a small 'project' help to troubleshooting: https://github.com/gaelcolas/env_refresh

The issue is, if I run the configuration in the example/ folder: https://github.com/gaelcolas/Env_Refresh/blob/master/examples/dsc_configuration.ps1

It fails the first time, works the second, and then it's like 'works','fails' | Get-Random for subsequent attempts.

The class is meant to be very simple:

So is the configuration:
https://gist.github.com/gaelcolas/6f485856dcfcbf4be0bcd0c8f1ac8a2e

I'll add a gif of the output I get when I run it in the git repo's readme.

It's worth noting that on my laptop (Win 10 TP Fast ring), it works every time:

OS         : Windows 10
OS Version : 10.0.14390
PSVersion  : 5.1.14390.0

Any idea of what I might be doing wrong? Or does it sound like an issue with the WMF5 on Win2012r2?

  • This topic was modified 2 years, 2 months ago by  gael. Reason: Creating gist instead of links to github

July 18, 2016 at 3:37 pm

There were definitely some pain points with class-based resources at first, and so far, I still haven't used them in production. What do you mean by "fails", though? What error message are you seeing?

July 18, 2016 at 3:58 pm

Thanks Dave.
Here's what I get:

VERBOSE: [WIN-8SU88BLP5RK]: LCM:  [ Start  Resource ]  [[Env_Refresh]TESTVAR]
VERBOSE: [WIN-8SU88BLP5RK]: LCM:  [ Start  Test     ]  [[Env_Refresh]TESTVAR]
VERBOSE: [WIN-8SU88BLP5RK]:                            [[Env_Refresh]TESTVAR] Importing the module
Env_Refresh in force mode.
Object reference not set to an instance of an object.
    + CategoryInfo          : OperationStopped: (:) [], CimException
    + FullyQualifiedErrorId : System.NullReferenceException
    + PSComputerName        : localhost

VERBOSE: [WIN-8SU88BLP5RK]: LCM:  [ End    Test     ]  [[Env_Refresh]TESTVAR]  in 0.0780 seconds.
The PowerShell DSC resource '[Env_Refresh]TESTVAR' with SourceInfo 'C:\Users\Administrator\AppData\Local\Temp
\kitchen\modules\Env_Refresh\examples\dsc_configuration.ps1::5::9::Env_Refresh' threw one or more
non-terminating errors while running the Test functionality. These errors are logged to the ETW channel
called Microsoft-Windows-DSC/Operational. Refer to this channel for more details.
    + CategoryInfo          : InvalidOperation: (:) [], CimException
    + FullyQualifiedErrorId : NonTerminatingErrorFromProvider
    + PSComputerName        : localhost

VERBOSE: [WIN-8SU88BLP5RK]: LCM:  [ End    Set      ]
The SendConfigurationApply function did not succeed.
    + CategoryInfo          : NotSpecified: (root/Microsoft/...gurationManager:String) [], CimException
    + FullyQualifiedErrorId : MI RESULT 1
    + PSComputerName        : localhost

VERBOSE: Operation 'Invoke CimMethod' complete.
VERBOSE: Time taken for configuration job to complete is 0.176 seconds


[10.111.111.113]: PS C:\Users\Administrator\AppData\Local\Temp\kitchen\modules\Env_Refresh>

It errors less often when I don't have another configuration entry AFTER my Env_Refresh TESTVAR {...}.

Also added a gif on my repo's readme:
https://github.com/gaelcolas/Env_Refresh/blob/master/README.md

It took 4 tries before actually raising the error.

  • This reply was modified 2 years, 2 months ago by  gael. Reason: Adding link to gif output example

July 18, 2016 at 4:10 pm

I've seen some people report that same error on the MVP mailing list as well. If Microsoft has fixed it in the latest Fast Ring builds, great (once that version of PowerShell hits general release on the downlevel operating systems.)

I don't know if this will help, but in the email thread I'm looking at, they mention that the error was only happening if they had the LCM's DebugMode set to something other than 'None'. (ForceModuleImport, etc).

July 19, 2016 at 8:50 am

This was spot on, the problem exist only when the Debug mode is set to something else than NONE.
On my Test-Kitchen configuration file .kitchen.yml I had

provisioner:
    name: dsc
    dsc_local_configuration_manager_version: wmf5
    dsc_local_configuration_manager:
      reboot_if_needed: true
      configuration_mode_frequency_mins: 15
      debug_mode: All

Changing with debug_mode: None fixed my issue. (or amending the LCM via Set-DscLocalConfigurationManager)

After that I tested on my laptop with the debug_mode: All, and it still worked.
I suspect that bug has been fixed in WMF 5.1 (PSVersion 5.1.14390.0), but confirmation would be great (we may have to wait for WMF5.1 release and its release notes).

I have opened a UserVoice for this as I could not find any: https://windowsserver.uservoice.com/forums/301869-powershell/suggestions/15273825-dsc-class-resource-fails-intermittently-when-debug

  • This reply was modified 2 years, 2 months ago by  gael. Reason: adding link to UserVoice