Skip to content
This repository has been archived by the owner on Jun 14, 2024. It is now read-only.

Enviroment: Enviroment sets nonExpaned path #180

Open
mh185277 opened this issue Jan 31, 2020 · 5 comments
Open

Enviroment: Enviroment sets nonExpaned path #180

mh185277 opened this issue Jan 31, 2020 · 5 comments
Labels
needs investigation The issue needs to be investigated by the maintainers or/and the community.

Comments

@mh185277
Copy link

Details of the scenario you tried and the problem that is occurring

Environment EnvironmentPath {
	Ensure = "Present"
	Path = $true
	Name = "Path"
	Value = "C:\myPath\forExample"
}

Verbose logs showing the problem

The $env:path is changed from C:\Windows\system32;C:\Windows; to %SystemRoot%\system32;%SystemRoot%;
(Custom path is added correctly, but problem is with changing C:\Windows to %SystemRoot%

Suggested solution to the issue

n/a

The DSC configuration that is used to reproduce the issue (as detailed as possible)

# insert configuration here

Configuration Config
{
Import-DscResource -ModuleName PSDesiredStateConfiguration

Node $NodeName
{
	ScEnvironment EnvironmentConfiguration
	{
	}
}

}

The operating system the target node is running

OsName : Microsoft Windows 10 Enterprise LTSC
OsOperatingSystemSKU : 125
OsArchitecture : 64-bit
WindowsVersion : 1809
WindowsBuildLabEx : 17763.1.amd64fre.rs5_release.180914-1434
OsLanguage : en-US
OsMuiLanguages : {en-US}

Version and build of PowerShell the target node is running

Name Value


PSVersion 5.1.17763.771
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17763.771
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

Version of the DSC module that was used ('dev' if using current dev branch)

latest

@PlagueHO PlagueHO added the question The issue is a question. label Apr 2, 2020
@PlagueHO
Copy link
Contributor

PlagueHO commented Apr 2, 2020

Hi @MartinNcr ,

Sorry about the delay in getting back to you:

I've just noticed that the resource your config is using the Environment resource in the inbox PSDesiredStateConfiguration resource module. Those are the ones that come with Windows and are much older than this one. Can you instead use the Environment resource in this module: PSDscResources

PSDscResources is a replacement for the Inbox resources. It is supported. There is also a community version of this module (xPSDesiredStateConfiguration) that would also work but may differ in function from the PSDscResources module.

@Ryfteh
Copy link

Ryfteh commented Apr 14, 2020

This still isn't working, even in the PSDscResources module.

If you look under:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment at the Path variable before it gets set by the resource, it will be of type REG_EXPAND_SZ, but afterwards it becomes a REG_SZ

@PlagueHO PlagueHO added needs investigation The issue needs to be investigated by the maintainers or/and the community. and removed question The issue is a question. labels Apr 14, 2020
@PlagueHO
Copy link
Contributor

Hi @Ryfteh - ah, I this I see part of the problem:

We are using Set-ItemProperty (see this line) to set registry key value. If the registry key does not exist then this gets created as a REG_SZ rather than a REG_EXPAND_SZ.

So this works fine if updating the Path variable as this is already set to a REG_EXPAND_SZ, but any other path type that is newly created by the resource will create this as a REG_SZ.

However, this doesn't explain the following behaviors that you're seeing:

  1. Existing REG_EXPAND_SZ being replaced by a REG_SZ.
  2. Why the Path string is being expanded when written to the registry as this isn't something the resource does (it is written as is).

Is there any more information that can be provided, such as an example config that demonstrates this problem? If I can replicate then I can trace it back.

@Ryfteh
Copy link

Ryfteh commented Apr 14, 2020

Sorry for the minimal information provided. I’ll provide system info and give an example when I sit down at my computer next.

@Ryfteh
Copy link

Ryfteh commented Apr 15, 2020

That's my fault, I seen one error and thought it was another. My registry property type starts as a REG_SZ, so this doesn't cause it to change.

I am still having an issue, but I don't think it still pertains to this topic, so I'll create a seperate issue to track it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs investigation The issue needs to be investigated by the maintainers or/and the community.
Projects
None yet
Development

No branches or pull requests

3 participants