在我们学习PowerShell的初始阶段,我们最需要知道的应该是PowerShell本身给我们提供那些原生的Cmdlets。为了达到这个目的,使用PowerShell的get-command是个不二之选。

为了了解这个命令输出的是什么对象,我们可以输入下面的命令进行了解

Get-Command|Get-Member

从输出种我们可以看到

PowerShell原生Cmdlets Get-Command详细使用介绍_PowerShell

PowerShell原生Cmdlets Get-Command详细使用介绍_Windows_02

PowerShell原生Cmdlets Get-Command详细使用介绍_应用程序_03

从上面三个图,我们可以看到Get-Command输出别名,function 和Cmdlet三种对象。通过man 命令可以查看命令帮助:

摘要
    获取有关 cmdlet 以及有关 Windows PowerShell 命令的其他元素的基本信息。


语法
    Get-Command [[-Name] <string[]>] [-CommandType {Alias | Function | Filter |
     Cmdlet | ExternalScript | Application | Script | All}] [[-ArgumentList] <O
    bject[]>] [-Module <string[]>] [-Syntax] [-TotalCount <int>] [<CommonParame
    ters>]

    Get-Command [-Noun <string[]>] [-Verb <string[]>] [[-ArgumentList] <Object[
    ]>] [-Module <string[]>] [-Syntax] [-TotalCount <int>] [<CommonParameters>]


说明
    Get-Command cmdlet 获取会话中 Windows PowerShell 命令的 cmdlet 及其他元素(
例如,别名、函数、筛选器、
    本和应用程序)的基本信息。

    Get-Command 直接从 cmdlet、函数、脚本或别名的代码中获取其数据,而不像 Get-He
lp 那样从帮助主题文件中获取其信息。

    如果不使用参数,“Get-Command”将获取当前会话中的所有 cmdlet 和函数。“Get-C
ommand *”获取所有 Windows Pow
    erShell 元素以及 Path 环境变量 ($env:path) 中的所有非 Windows-PowerShell 文
件。它将这些文件归入“Ap
    lication”命令类型。

    可以使用 Get-Command 的 Module 参数查找通过添加 Windows PowerShell 管理单元
或导入模块而添加到会话中的命令


相关链接
    Online version: http://go.microsoft.com/fwlink/?LinkID=113309
    about_Command_Precedence
    Get-Help
    Get-PSDrive
    Get-Member
    Import-PSSession
    Export-PSSession

备注
    若要查看示例,请键入: "get-help Get-Command -examples".
    有关详细信息,请键入: "get-help Get-Command -detailed".
    若要获取技术信息,请键入: "get-help Get-Command -full".

可以通过最后的连接查看get-command的详细使用。