Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
It is same as ms-dos command where.exe
function Where-command
{
param(
[Parameter(ValueFromPipeline=$true,Mandatory=$true)]
[string] $Name
)
begin
{
}
process
{
$path = [environment]::GetEnvironmentVariable("PATH")
$folders = $path.split(';')
foreach($folder in $folders){
$result = Join-Path $folder -ChildPath $Name | Test-Path
if($result -eq $true){
return $result
}
}
return $false
}
end
{
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment