# If file exists if (Test-Path "$directory/$filename" -PathType Leaf) { ... } # If file doesn't exist if (-not (Test-Path "$directory/$filename" -PathType Leaf)) { ... }