LoginSignup
130
99

More than 5 years have passed since last update.

PowerShellでwhichコマンド

Last updated at Posted at 2014-05-24

最近Windowsを触る割合が減ったのでよく忘れる。。

UNIXのwhichコマンドのように、コマンドレットの詳細を調べるのはGet-Command(エイリアス: gcm)である。しかしそのままでは表示がわかりにくい。。

> gcm notepad

CommandType     Name                                               ModuleName
-----------     ----                                               ----------
Application     notepad.exe

notepad.exeが、どのパスに存在しているのかが知りたいからコマンドを調べてるのに!!肝心の情報が表示されていない。

Format-List(エイリアス: fl)をかませると、いい感じの表示になる。

> gcm notepad | fl


Name            : notepad.exe
CommandType     : Application
Definition      : C:\Windows\System32\notepad.exe
Extension       : .exe
Path            : C:\Windows\System32\notepad.exe
FileVersionInfo : File:             C:\Windows\System32\notepad.exe
                  InternalName:     Notepad
                  OriginalFilename: NOTEPAD.EXE.MUI
                  FileVersion:      6.3.9600.16384 (winblue_rtm.130821-1623)
                  FileDescription:  メモ帳
                  Product:          Microsoft® Windows® Operating System
                  ProductVersion:   6.3.9600.16384
                  Debug:            False
                  Patched:          False
                  PreRelease:       False
                  PrivateBuild:     False
                  SpecialBuild:     False
                  Language:         日本語 (日本)

もしくは

> (gcm notepad).Definition

でもファイルパスが得られる。でも長くて覚えられないので、Format-Listを使うことにする。

130
99
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
130
99