Edit (Add / Remove) System Path Variable via PowerShell

Ok, so I found a ton of blogs / posts out there about changing the System Path Variable in Windows, but not a way I'd want to do it, so I came up with my own script for adding / removing items.

What it does.

  • Grabs Current System Environment Path Variable and Places into a PowerShell Variable "Environment"
  • Checks for "rules" of items you want to delete, then deletes them from the PowerShell Variable
  • Adds any "Additional Items" you specify into the PowerShell Variable
  • Commits the PowerShell Variable "Environment" as the Updated System Path Variable.

In Action: (Please Note, the added and removed items are ONLY for example, I'm NOT suggesting you do this)

Code:

 

Posted Originally on GARYTOWN.COM

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.