Home QuickTipps “Spaces” resolve to current path
 

“Spaces” resolve to current path

When you use Test-Path to check whether a file or folder exists, be aware that spaces resolve to the current path.

So this line always returns true:

Test-Path ' '

In fact, it points to the current path. The next two lines produce the same result:

Resolve-Path ' '
Resolve-Path .

It looks like this is a bug in the underlying filesystem provider code. It may cause unexpected results when a path variable accidentally contains only space(s).