Verifying the Existence of a File or Folder
One of the primary uses of Test-Path is to verify the existence of a file or folder. For example, this command checks to see whether the file C:\Scripts\Test.txt exists:
[crayon-6a6187f54a0ac441421062/]
Test-Path returns True if the file exists, and returns False if the file does not exist.
As is usually the case with cmdlets, you can use wildcards with Test-Path. For example, this script tells you whether or not there are any .wma files in C:\Scripts:
[crayon-6a6187f54a0b1926759464/]
Did someone ask if you can you check for the existence of registry keys using Test-Path? Of course you can:
[crayon-6a6187f54a0b2159341327/]