Please feel free to provide feedback or file bugs here.

DSC Environment Resource Expands PATH Environment Variable

Votes from Connect: 3

Original Date Submitted: 11/25/2015 1:33:11 AM

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

Frequency: Desired State Configuration (DSC)
Regression: Prior to running the below DSC ensure that the environment variable is not already expanded/mangled, you can do this either by pulling up the System Environment Variables Dialog from System, or by querying the registry:

REG.EXE QUERY "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /V "PATH"

We should expect to see something similar to the following:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
PATH REG_EXPAND_SZ %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SystemRoot%\System32\WindowsPowerShell\v1.0\

Create a new DSC Script with the following:

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

Apply the above configuration.

We now see that the path has been mangled, expanding the value to a REG_SZ, this is NOT EXPECTED:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
PATH REG_SZ C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\DevApps\System\notepad2

Problem Description:
When utilizing the Environment Resource from the PSDesiredStateConfiguration Version 1.1 package and modifying the PATH Environment Variable the PATH is expanded, this is unexpected and limits the usefulness of this Resource.

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

Repro Steps:
Prior to running the below DSC ensure that the environment variable is not already expanded/mangled, you can do this either by pulling up the System Environment Variables Dialog from System, or by querying the registry:

REG.EXE QUERY "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /V "PATH"

We should expect to see something similar to the following:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
PATH REG_EXPAND_SZ %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SystemRoot%\System32\WindowsPowerShell\v1.0\

Create a new DSC Script with the following:

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

Apply the above configuration.

We now see that the path has been mangled, expanding the value to a REG_SZ, this is NOT EXPECTED:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
PATH REG_SZ C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\DevApps\System\notepad2

Expected Results:
It is expected that the Path, including the replacements, be preserved during this operation. The bug appears to be that the developer of the Resource did not read the REG_EXPAND_SZ and probably just directly queried the value via Powershell (which by default will perform the expansion) and appended the requested change.

Internal BugId: 16001

7 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 →

    1 comment

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

      Feedback and Knowledge Base