Summary: Learn how to use Windows PowerShell to find a file or a folder.
How can I use Windows PowerShell to determine if a variable contains a path that leads to a file or folder?
Use the Test-Path cmdlet to test the path stored in the variable, and then specify the PathType parameter,
for example:
PS C:\> $fso = "c:\fso"
PS C:\> $file = "C:\fso\backup.ps1"
PS C:\> Test-Path $fso -PathType leaf
False
PS C:\> Test-Path $file -PathType leaf
True