Skip to content

Instantly share code, notes, and snippets.

@btipling
Created May 31, 2020 21:14
Show Gist options
  • Save btipling/567873fd2243307d1995977655cf5de8 to your computer and use it in GitHub Desktop.
Save btipling/567873fd2243307d1995977655cf5de8 to your computer and use it in GitHub Desktop.
A script that prints whether a file exists or not.
param ([string] $Path)
Get-Item -Path $Path -ErrorAction SilentlyContinue -ErrorVariable test | Out-Null
if ($test.Count -eq 0) {
Write-Host "The file at $Path exists!"
}
else {
Write-Host "The file at $Path was not found."
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment