In my function i have 3 no mandatory and no positional parameters Folder1, Folder2 and Folder3
, before running my function i would like to check for each select
You can pass an array to Test-Path
Test-Path c:, d:, e:
True
True
True
EDIT
So I believe from your comment that you have something like this:
$mypaths = "c:","d:",$null
Test-Path $mypaths
Which issues the following error:
Test-Path : Cannot bind argument to parameter 'Path' because it is null.
Then you can try this:
$mypaths = "c:","d:",$null
$mypaths | Foreach { if ($_){Test-Path $_}}
Which results in only two valid paths.
So you could consider checking the returned values:
$valid = $mypaths | Foreach { if ($_){Test-Path $_}}
write-host "Variable `$mypaths contains $($mypaths.count) paths, and $($valid.count) were found valid"
Which outputs:
Variable $mypaths contains 3 paths, and 2 were found valid