Test-Path

Description

Determines whether all elements of a path exist.

Command
Test-Path
Examples
Check if a file exists
Test-Path -Path 'C:\Windows\System32\kernel32.dll'
Check if a path is a directory
Test-Path -Path 'C:\Windows' -PathType Container
Parameters
Parameter Type Required Description
[-Path] <String[]> string No Specifies the path to test.
[-PathType <TestPathType>] string No Specifies the type of the last element in the path. Options: Any, Container, Leaf.
Command Info
Category: File System
Type: Powershell
Views: 12
Status: Active
Tags
powershell file directory exists check