Skip to main content David Edelstein's Blog

🦙
🦙

Update Windows Environment Variables from Powershell

Published: 2015-12-09
dave@edelsteinautomotive.com
David Edelstein

Powershell makes it extremely easy to update the current session’s environmental variables by just reading and writing from $env:VARIABLE

But updating the systems default environment variables requires you to update the registry.  Here’s the snippet to do that:


Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINESystemCurrentControlSetControlSession ManagerEnvironment' `
-Name VARIABLENAME `
-Value VARIABLEVALUE