Parse env:Path with PowerShell

wp-read-more-redirectwp-read-more-redirectNo Gravatar

The environment variable PATH (combined SYSTEM PATH and USER PATH) can be tricky to parse if you want to check for each folder it contains.  This is due to the support of various formatting styles.  For example, this is a valid PATH statement:

Notice the differences

  • Folder with spaces
  • Folder without spaces
  • Folder with an ending backslash (\)
  • Folder without an ending backslash (\)
  • Folder with a semicolon in the middle
  • Folder with a semicolon at the end
  • Blank folder (;;)

A few references can be found…

But, I could find no simple method to parse this complexity so I wrote a PowerShell Function to handle it.

continue reading on CatapultSystems.com

January 30, 2018

Posted In: Scripting

Tags: ,