コマンドの調べ方

.NET Frameworkに関して調べたい時は、MSDNのリファレンスなり、TIPSのサイトをぐぐるなり、何とでもなる。
Monad固有のCmdletはどうやって調べるかという話。

get-commandというCmdletを使うと、どんなCmdletがあるか、簡単な使い方が分かる。

MSH> get-command get-help

Command Type    Name                      Definition
------------    ----                      ----------
Cmdlet          get-help                  get-help [[-Name] String] [-Catego...

Definitionが見たいんだけど、というような時は、select-objectを使うと、パイプで渡されたレコードのうち、選択したプロパティだけを返してくれる。SQLの射影みたいな操作。

MSH> get-command get-help|select-object Definition

Definition
                  • -
get-help [[-Name] String] [-Category String[]] [-Component String] [-Functio...

または、format-listを使うと、下記のように1レコードを複数行に表示してくれる。

MSH> get-command get-help|format-list


Name          : get-help
CommandType   : Cmdlet
Definition    : get-help [[-Name] String] [-Category String[]] [-Component Stri
               ng] [-Functionality String] [-Role String] [-Verbose] [-Debug]
               [-ErrorAction ActionPreference] [-ErrorVariable String] [-OutVa
               riable String] [-OutBuffer Int32]

Path          :
AssemblyInfo  :
DLL           : C:\Program Files\Microsoft Command Shell\System.Management.Auto
               mation.DLL
HelpFile      : System.Management.Automation.dll-Help.xml
ParameterSets : {__AllParameterSets}
Type          : System.Management.Automation.Commands.GetHelpCommand
Verb          : get
Noun          : help

詳しい説明が表示されるのは、get-helpというCmdlet。UNIXでいうmanみたいな感じ。
get-help [Cmdlet]というように使う。