أخبار ساخنة

How to Check a specific path using PowerShell


This section is about cmdlets that are installed with the PowerShell module in Microsoft PowerShell Management.

Contains cmdlets that help you manage Windows in PowerShell.


Determines whether all path elements are present or not.

The result is True if all elements are present and False if any of them are missing.

Examples of Test-Path

example 1

path test

Test-Path -Path "C:\Documents and Settings\TEST"


This command checks if all the items in the path are present i.e. the C driver, Documents and Settings folder, and TEST folder.

If any of them are missing, the result of the command will be False.

Otherwise, the result of the command will be True.

Example 2

Check if there are any files other than the specified type

Test-Path -Path "C:\CAD\Commercial Buildings\*" -Exclude *.dwg


This command checks if there are any files in the Commercial Buildings folder that are not .dwg files.

In this case because the folder contains only .dwg files, the result is False.