I have a script which allows the user to specify a location for a file which the script will write to. I want to check that the given string represents an absolute, rather than relative, file path. So this would pass:
C:\Folder\MyFile.txt
But these would fail:
.\Folder\MyFile.txt
..\MyFile.txt
MyFile.txt
Regardless of whether those files/folders exist already.
I'm not concerned with checking for e.g. invalid characters (which other questions I found while searching were concerned with). I could use a quick and dirty regular expression to check it starts with "^[a-zA-Z]:\" but I was wondering if the functionality already existed in PowerShell to do this.
If the script detects it's not an absolute path, the script will then convert it to a full path by inserting the full path of the current directory - so if there's a function which can do that directly then that will also be useful.