Powershell - Check Folder Existence



Cmdlet

Test-Path cmdlet is used to check existence of a folder.

Example 1

In this example, we're having a folder test in D:\temp directory

Type the following command in PowerShell ISE Console

Test-Path D:\temp\test

Output

You can see following output in PowerShell console.

Test-Path D:\temp\test
True

Example 2

In this example, we're not having a folder named test2 in D:\temp directory

Type the following command in PowerShell ISE Console

Test-Path D:\temp\test2

Output

You can see following output in PowerShell console.

Test-Path D:\temp\test2
False
powershell_files_folders.htm
Advertisements