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 fully working method to parse this complexity so I wrote a PowerShell Function to handle it.

To prove it out:

Happy coding!