Quantcast
Channel: Hey, Scripting Guy! Blog
Viewing all articles
Browse latest Browse all 3333

PowerTip: Use PowerShell to Find File or Folder

$
0
0

Summary: Learn how to use Windows PowerShell to find a file or a folder.

Hey, Scripting Guy! Question How can I use Windows PowerShell to determine if a variable contains a path that leads to a file or folder?

Hey, Scripting Guy! Answer 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


Viewing all articles
Browse latest Browse all 3333

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>