Please feel free to provide feedback or file bugs here.

DSC Environment Resource Does Not Allow Duplicate PATH Definitions

Votes from Connect: 4

Original Date Submitted: 11/25/2015 1:53:18 AM

Description:
********Contact Information********
Handle: aolszowka
Site Name: PowerShell
Feedback ID: 2054079
***************************************

Frequency: Desired State Configuration (DSC)
Regression: Assume that you've had several machines in production for a long period of time, these machines may possibly have invalid configurations within them (for example perhaps you have switched text editors which require a change to the PATH environment variable) a robust configuration will attempt to perform cleanup of known invalid configurations prior to implementing its desired states.

Such a DSC script would look similar to the below:

Environment EnvVar_PATH_Notepad2
{
Name = "PATH"
Value = "C:\DevApps\System\notepad2"
Path = $true
Ensure = "Present"
}

Environment EnvVar_PATH_NotepadPlusPlus
{
Name = "PATH"
Value = "C:\DevApps\System\notepadpp"
Path = $true
Ensure = "false"
}

Additionally a best practice would be to clearly define each new addition to the path as its own Resource, thus allowing for an easy way to maintain removals as the configuration grows older, adding additional PATH's yield the same error as below.

However apparently a design decision (unsure if it is in the DSC Framework or the Resource itself) prevents you from using the Environment Resource in the above fashion (Tested in WMF 5 Production Preview in Server 2008 R2), erroring with the following when attempting to "compile" the script:

Test-ConflictingResources : A conflict was detected between resources '[Environment]EnvVar_PATH_Notepad2' and '[Environment]EnvVar_PATH_NotepadPlusPlus' in node 'master_ut6t'. Resources have identical key properties but there are differences in the following non-key properties: 'Ensure;Value'. Values 'Present;C:\DevApps\System\notepad2' don't match values 'false;C:\DevApps\System\notepadpp'. Please update these property values so that they are identical in both cases.

Problem Description:
When utilizing the Environment Resource from the PSDesiredStateConfiguration Version 1.1 package and attempting to configure the PATH environment variable multiple times, an error is thrown:

Test-ConflictingResources : A conflict was detected between resources '[Environment]EnvVar_PATH_Notepad2' and '[Environment]EnvVar_PATH_NotepadPlusPlus' in node 'master_ut6t'. Resources have identical key properties but there are differences in the following non-key properties: 'Ensure;Value'. Values 'Present;C:\DevApps\System\notepad2' don't match values 'false;C:\DevApps\System\notepadpp'. Please update these property values so that they are identical in both cases.

This severely limits the usefulness of this resource when attempting to ensure an idempotent state.

Please see the Reproduction Steps for a use-case.

Product Studio item created by Connect Synchronizer due to creation of feedback ID 2054079 (http://connect.microsoft.com/PowerShell/feedback/ViewFeedback.aspx?FeedbackID=2054079).

Repro Steps:
Assume that you've had several machines in production for a long period of time, these machines may possibly have invalid configurations within them (for example perhaps you have switched text editors which require a change to the PATH environment variable) a robust configuration will attempt to perform cleanup of known invalid configurations prior to implementing its desired states.

Such a DSC script would look similar to the below:

Environment EnvVar_PATH_Notepad2
{
Name = "PATH"
Value = "C:\DevApps\System\notepad2"
Path = $true
Ensure = "Present"
}

Environment EnvVar_PATH_NotepadPlusPlus
{
Name = "PATH"
Value = "C:\DevApps\System\notepadpp"
Path = $true
Ensure = "false"
}

Additionally a best practice would be to clearly define each new addition to the path as its own Resource, thus allowing for an easy way to maintain removals as the configuration grows older, adding additional PATH's yield the same error as below.

However apparently a design decision (unsure if it is in the DSC Framework or the Resource itself) prevents you from using the Environment Resource in the above fashion (Tested in WMF 5 Production Preview in Server 2008 R2), erroring with the following when attempting to "compile" the script:

Test-ConflictingResources : A conflict was detected between resources '[Environment]EnvVar_PATH_Notepad2' and '[Environment]EnvVar_PATH_NotepadPlusPlus' in node 'master_ut6t'. Resources have identical key properties but there are differences in the following non-key properties: 'Ensure;Value'. Values 'Present;C:\DevApps\System\notepad2' don't match values 'false;C:\DevApps\System\notepadpp'. Please update these property values so that they are identical in both cases.

Expected Results:
The expectation is that for the PATH environment variable (or in fact any environment variable in which you have the Path property set to $true) that you are allowed to call the Resource multiple times without issue.

Internal BugId: 16002

12 votes
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    Signed in as (Sign out)

    We’ll send you updates on this idea

    AdminJoey Aiello [MSFT] (Program Manager, Windows Server) shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

    4 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      Signed in as (Sign out)
      Submitting...
      • angrychai commented  ·   ·  Flag as inappropriate

        It so ilogical how it has been implemented that I though that setting the path=$true flag was to allow multiple path variables

      • Eric Pang commented  ·   ·  Flag as inappropriate

        I too recently experience this issue after upgrading from WMF 5.0 to WMF 5.1.
        I am using Partial DSC and two of my scripts use the Environment resource to add a path.
        I get the following error when I start-dscconfiguration.

        VERBOSE: Perform operation 'Invoke CimMethod' with following parameters, ''methodName' = ApplyConfiguration,'className' = MSFT_DSCLocalConfigurationManager,'namespaceName' = root/Microsoft/Windows/DesiredStateConfiguration'.
        VERBOSE: An LCM method call arrived from computer MYCOMPUTER with user sid S-1-5-21-1064954374-356710528-937385128-34335.
        VERBOSE: [DESTCOMPUTER]: [] Starting consistency engine.
        The resources ('[Environment]SetInstantClientPath' and '[Environment]SqlCmdPath') have conflicting values of the following properties: 'Value'. Ensure that their values match. Merging of partial configurations failed. LCM
        failed to start desired state configuration manually.
        + CategoryInfo : ResourceExists: (root/Microsoft/...gurationManager:String) [], CimException
        + FullyQualifiedErrorId : MI RESULT 11
        + PSComputerName : DESTCOMPUTER

        My partial configs contain the following:

        Environment SqlCmdPath {
        Name = "Path"
        DependsOn = "[Package]InstallSQLServer2012CmdLineUtils_64bit"
        Ensure = "Present"
        Path = $true
        Value = "$env:ProgramFiles\Microsoft SQL Server\110\Tools\Binn"
        }

        Environment SetInstantClientPath {
        Name = "Path"
        DependsOn = "[Archive]InstallInstantClientBasic","[Archive]InstallInstantClientSqlplus"
        Ensure = "Present"
        Path = $true
        Value = "$env:SystemDrive\instantclient_11_2"
        }

      • Colyn1337 commented  ·   ·  Flag as inappropriate

        Agree with Bartek, there should be a way to append the Path variable on machines using this resource.

      • Bartek Bielawski commented  ·   ·  Flag as inappropriate

        I would suggest slightly different approach. Having multiple items with the same key is not possible, but it really feels like if Path = $true , Name should just be ignored (and used as a key for configuration item only) and any value should be appended to PATH. Otherwise the value of path = $true is limited. No to mention how difficult it is to use this resource if partial configurations are used. :(

      Feedback and Knowledge Base