where.exe PowerShell alternative

Previously I’ve blogged about where.exe utility

Today I found a true PowerShell alternative

Get-Command -CommandType Application -ErrorAction SilentlyContinue -Name git | Select-Object -ExpandProperty Definition

UPD: Forgot to mention -ErrorAction SilentlyContinue. Without it the command will fail of the application couldn’t be found

Advertisements

About mnaoumov

Senior .NET Developer in Readify
This entry was posted in Uncategorized and tagged . Bookmark the permalink.

2 Responses to where.exe PowerShell alternative

  1. Mike Chaliy says:

    gcm git | select Definition

    • mnaoumov says:

      Without ExpandProperty you will get not a string result but wrapped object. For scripting purposes I usually want to save the result into a variable and don’t worry about the wrapper. Secondly, I’ve already blogged about aliases. I believe they only good for REPL mode. For readability I tend to use more clear but verbose syntax.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s