Skip to content

Instantly share code, notes, and snippets.

@gravejester
Last active November 1, 2024 12:38
Show Gist options
  • Save gravejester/e6cafe41407e2b2462c536ece5ca0a37 to your computer and use it in GitHub Desktop.
Save gravejester/e6cafe41407e2b2462c536ece5ca0a37 to your computer and use it in GitHub Desktop.
Check if file exists in environment paths
function Test-ExistInEnvPath($fileName) {
$envPaths = ($env:Path -split ';') | Where-Object {$_ -ne ''}
$envPaths | ForEach-Object {
if (Test-Path -Path (Join-Path -Path $_ -ChildPath $fileName)) {
Write-Output $true
} else {
Write-Output $false
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment