Powershell - Check Folder Existence


Advertisements

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

Useful Video Courses


Video

Powershell for beginners

15 Lectures 3.5 hours

Fabrice Chrzanowski

Video

Learning Task Automation using Windows PowerShell

35 Lectures 2.5 hours

Vijay Saini

Video

The Complete PowerShell 7 course: Beginner To Advanced

145 Lectures 12.5 hours

Fettah Ben

Advertisements