Skip to content

Instantly share code, notes, and snippets.

@kkamegawa
Created January 7, 2016 12:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kkamegawa/bceb9cf9ff6d0e539c64 to your computer and use it in GitHub Desktop.
Save kkamegawa/bceb9cf9ff6d0e539c64 to your computer and use it in GitHub Desktop.
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