Test-Path -isValid with wildcards
<p>I am trying to validate paths so I can provide meaningful error logging, and I am running into an issue with wildcards.
This returns False unless there is a folder and something in it, but it should return True.</p>

<pre><code>Test-Path -isValid -path:"C:\Somefolder\*"
</code></pre>

<p>And like this doesn't work because -literalPath doesn't interpret wildcards.</p>

<pre><code>Test-Path -isValid -literalPath:"C:\Somefolder\*"
</code></pre>

<p>My sense is that I am going to have to test for wildcards, and if found <code>Test-Path -isValid</code> on the parent folder. But then I run into issues with <code>-like</code> because I can't really test for a condition like *.EXT. Which has me thinking the only real answer is a RegEx, but this feels like something so basic I shouldn't really need to resort to a RegEx and I am probably missing something.
Note that for a variety of reasons I am limited to PS v2.</p>

<p>EDIT: To clarify, the actual path is variable. Users provide a path in an XML file, I then validate the path and do something with it. So, it might be that the user wants to delete all TXT files in a certain path. Or all files. Or even all files and subfolders. Thus <strong>C:\Somefolder\*</strong> needs to be supported. If they had <strong>C:\\Somefolder\*</strong> or <strong>C:Somefolder\*</strong> I would want to flag that as an invalid path. But <strong>C:\Somefolder\*</strong> when Somefolder doesn't exist is not an invalid path, it's a missing folder and I want to flag that as a different error.</p>