I recently made the switch to creating Class-based PowerShell DSC resources. In this, I discovered that each time I use $env:HOMEDRIVE it returns a null value. I tried enclosing it with ‘$()’ but that didn’t help.


Is there a way to use Environment Variables in the code that I’m missing?


Thanks in advance,


DSC resources by LCM runs with system account by default. You will have to run as a specific user to use this environment variable.

Below links will help.

Thanks kvprasoon. That makes perfect sense.