I have a function that accepts a string array parameter of files and I would like to use Test-Path (or something else) to ensure that all the files in the string array param
As @Matt said. Test-Path
already accepts pipeline input, so you really just have to send the array directly in:
@($path1, $path2) | Test-Path
Which then returns:
> @("C:\foo", "C:\Windows") | Test-Path
False
True
If you just want to know if ALL of them exist:
($pathArray | Test-Path) -notcontains $false
Which yields:
False