DSC Environment resource failing to see environment variable it has set

This topic contains 3 replies, has 2 voices, and was last updated by Profile photo of Peter McEvoy Peter McEvoy 5 months, 2 weeks ago.

  • Author
  • #63734
    Profile photo of Peter McEvoy
    Peter McEvoy

    (cross-post from http://serverfault.com/questions/831295/dsc-environment-resource-failing-to-see-environment-variable-it-has-set)

    I'm using DSC to provision virtual machines. The VMs are setup to pull a DSC configuration from a pull server. All is well with this. However, I noticed that I am frequently seeing:

    Job {8B376B76-EDE7-11E6-80FC-3649808F2EC1} : 
    From LCM, message is 
        Completed processing test operation. The operation returned False.

    In the event logs. Using a useful tip I found here https://powershell.org/forums/topic/lcm-event-log-entries-for-different-configurationmode-settings/, I can see that an Environment variable resource is failing – despite the fact that the environment variable was created:

    VERBOSE: [TESTEZE-CDEUURA]: LCM:  [ Start  Resource ]  [[Environment]EZELOGS]
    VERBOSE: [TESTEZE-CDEUURA]: LCM:  [ Start  Test     ]  [[Environment]EZELOGS]
    VERBOSE: [TESTEZE-CDEUURA]:                            [[Environment]EZELOGS] (NOT FOUND) Environment variable 'EZELOGS'
    VERBOSE: [TESTEZE-CDEUURA]: LCM:  [ End    Test     ]  [[Environment]EZELOGS] False in 0.0190 seconds.
    VERBOSE: [TESTEZE-CDEUURA]: LCM:  [ End    Resource ]  [[Environment]EZELOGS]

    (I know the environment variable was created because I can see it in the environment variables dialog).

    If I manually reboot the machine, the consistency check then passes.

    My LCM configuration is set to RebootIfNeeded=$true and ActionAfterReboot = 'ContinueConfiguration'.

    The resource definition is this:

    Environment EZELOGS {
        Name = "EZELOGS"
        Value = "C:\Logs"
        Ensure = "Present"

    The LCM is creating the variable, but it does not seem to be able to see the variable, and ends up cycling the configuration every 30mins. Any pointers?

    Environment is Windows Server 2012 R2 (I know, I know...), with Powershell 5, WMF 5.0 (from KB3134758)

  • #63778
    Profile photo of Alex Aymonier
    Alex Aymonier

    What happens if you close the PS window you are running the config and and re-open it? I believe (could be wrong) that your current PowerShell session is not aware of the new environment change until it is relaunched.

    • #63811
      Profile photo of Peter McEvoy
      Peter McEvoy

      I would be very surprised if it was the case, because I wanted the commands from the referenced tip to report what the *LCM* thinks the state of the system is, and not to report on my session..

      In any case, I executed the commands _after_ the event log reported the warning. So this is a completely new window _after_ the resources had been fulfilled by the LCM. (so I would expect my session to actually see the variables – unfortunately I had already rebooted the VM)

    • #63817
      Profile photo of Peter McEvoy
      Peter McEvoy

      I wanted to verify this for certain, so I ran up a new VM and applied the configuration without a reboot and yes, it is as I expected: a new powershell session can see the edits to


      , but when I run the actual configuration check commands, the LCM cannot see the system variable.

You must be logged in to reply to this topic.