PowerShell相当于BASH(etc)'type'命令?

mon*_*nny 6 windows shell powershell command-line-interface powershell-2.0

在*nix上,使用BASH(等)通过使用内置的'type'shell,询问系统命令所在的位置(等):

$ type cat
cat is /bin/cat
Run Code Online (Sandbox Code Playgroud)

Microsoft PowerShell 2.0中是否存在等效的"类型"命令?

pb2*_*b2q 8

相当于Get-Command.

PS C:\> Get-Command ls

CommandType     Name       Definition
-----------     ----       ----------
Alias           ls         Get-ChildItem
Application     ls.exe     D:\usr\local\wbin\ls.exe
Application     ls.exe     C:\Program Files (x86)\Git\bin\ls.exe
Run Code Online (Sandbox Code Playgroud)

Windows 10更新:

由于我发布了这个答案,似乎行为发生Get-Command了变化.要包含所有结果(以Un*x的样式type),现在我需要传递-All标志,如下所示:

PS C:\> Get-Command -All ls

CommandType     Name                 Version    Source
-----------     ----                 -------    ------
Alias           ls -> Get-ChildItem
Application     ls.exe               0.0.0.0    C:\Program Files (x86)\Git\usr\bin\ls.exe
Run Code Online (Sandbox Code Playgroud)

如评论中所述,这包括Definition以前行为的列.我无法确定添加定义列的命令行参数,但正如@voutasaurus在下面的注释中所指出的,可以使用:

PS C:\> (Get-Command -All ls).Definition
Get-ChildItem
C:\Program Files (x86)\Git\usr\bin\ls.exe
Run Code Online (Sandbox Code Playgroud)

版本信息供参考(我没有与原始答案文本相关的版本信息,但我猜它是Windows 7):

PS C:\> [System.Environment]::OSVersion.Version

Major  Minor  Build  Revision
-----  -----  -----  --------
10     0      15063  0
Run Code Online (Sandbox Code Playgroud)