Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Wondering what tools are available to remotely edit (find and replace actually) the PATH environment variable on all users workstations across the enterprise? We do use SCCM (formerly SMS), but I don't know if that provides the capability to do that. Is this possible with Powershell maybe?

share|improve this question
up vote 3 down vote accepted

I'd caution you about doing what Nick O'Neil suggests insofar as just blindly overwriting the PATH variable in the registry of all your client computers is likely to cause problems.

A quickie one-liner for a search-and-replace on a literal string in PowerShell would be (long line wrapped for readability-- this is all a single line):

Set-ItemProperty "HKLM:SYSTEM\CurrentControlSet\Control\Session Manager\Environment" Path -value ( (Get-ItemProperty "HKLM:SYSTEM\CurrentControlSet\Control\Session Manager\Environment" Path).Path -replace "OLD STRING", "NEW STRING")

You could run that as an Active Directory Startup Script on the affected computers. You could even get fancy and put some kind of flag in the registry (join the computer to a group that's denied rights to apply the GPO again, etc) to make the script only run once per computer.

share|improve this answer
I can't believe I wrote something in PowerShell. I feel sorta dirty. >smile< – Evan Anderson Oct 27 '10 at 20:53

Editing the registry could be one way of doing this, navigate to HKLM\System\Current Control Set\Control\Session Manager\Environment

If you save this registry change you could then deploy it across the organization via a group policy.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.