Script Repository

Check whether path exists

February 24, 2021

The script can be used with the If PowerShell script returns true condition to check whether a specific path exists. It returns True if all elements of the path exist and False if any are missing. The path can represent a file, a folder, a Windows Registry key or any other valid PowerShell provider path. For details, see Test-Path.


  • $path - Specifies the path to check. You can use value references (e.g. %username%, %department%) in the path. When the script is executed, they are replaced with values of the AD object on which the zcript is run. For example, if you specify %username%, the value reference is replaced with the username of the user account on which the script is run.
Edit Remove
$path = "\\SERVER\Share\%username%" # TODO: modify me

$Context.ConditionIsMet = $False
    $pathExists = Test-Path -Path $path -ErrorAction Stop

if ($pathExists)
    $Context.ConditionIsMet = $True

Comments ( 0 )
No results found.
Leave a comment