I configure PATH on multiple W2k3 servers in PowerShell to convert specific paths with empty spaces to their 8.3 equivalents. After several regular expression conversions, I run the following two commands:
$env:PATH = $path
[System.Environment]::SetEnvironmentVariable('PATH', $path,[System.EnvironmentVariableTarget]::Machine)
After starting, the path changes in a way that I did not expect. % SystemRoot% is evenly expanded to C: \ Windows. I don’t see where the apocalypse signals, but I would prefer to save% SystemRoot%, so I played until I got% SystemRoot% to appear on the path again, but when I make this path it no longer expands and does not expand anymore . Repeating the path in the CLI returns an unextended string (this is incorrect), and the commands in SystemRoot can no longer be found.
If I then add an empty entry to the ";;" Path without changing any other text in the PATH, it will start working correctly.
So my question is how to programmatically change the path using PowerShell so as not to drown out the variable extension in the path?
source
share