PowerTip: Check Syntax Options for PowerShell Cmdlet


Summary: Use the Get-Command cmdlet to check syntax options for a Windows PowerShell cmdlet.

  How can I easily find syntax options (parameter sets) that exist for a particular Windows PowerShell cmdlet?

  Use the Get-Command cmdlet and check the Definition property, for example:

(Get-Command Stop-Process).Definition

   

Comments (4)

  1. Greg Wojan says:

    Get-CASMailbox is a function — that’s why (Get-Command xxx).Definition results in what you see.

  2. Bjorn Houben says:

    Hmmm, didn’t know that one. I generally use: (Get-Help Stop-Process).syntax
    Because it’s easier to remember for me.

  3. shaik says:

    I have run this for (get-command get-casmailbox).definition , this is exchange command and I have done in Exchange management shell

    but I got this , let me know if this is expected if so why and how to fix

    PS C:windowssystem32> (Get-Command Get-CASMailbox).Definition

    param(

    [Alias(‘ea’)]
    ${ErrorAction},

    [Alias(‘pv’)]
    ${PipelineVariable},

    [Alias(‘vb’)]
    [switch]
    ${Verbose},

    [switch]
    ${ReadFromDomainController},

    [Alias(‘ov’)]
    ${OutVariable},

    ${SortBy},

    [switch]
    ${Monitoring},

    [Alias(‘wv’)]
    ${WarningVariable},

    [Alias(‘db’)]
    [switch]
    ${Debug},

    ${Credential},

    [Alias(‘ob’)]
    ${OutBuffer},

    [Alias(‘ev’)]
    ${ErrorVariable},

    ${OrganizationalUnit},

    [switch]
    ${ActiveSyncDebugLogging},

    ${Identity},

    [switch]
    ${IgnoreDefaultScope},

    [switch]
    ${ProtocolSettings},

    [Alias(‘wa’)]
    ${WarningAction},

    [switch]
    ${RecalculateHasActiveSyncDevicePartnership},

    ${DomainController},

    ${Filter},

    ${ResultSize},

    ${Anr},

    [switch]
    ${AsJob})

    Begin {
    try {
    $positionalArguments = & $script:NewObject collections.arraylist
    foreach ($parameterName in $PSBoundParameters.BoundPositionally)
    {
    $null = $positionalArguments.Add( $PSBoundParameters[$parameterName] )
    $null = $PSBoundParameters.Remove($parameterName)
    }
    $positionalArguments.AddRange($args)

    $clientSideParameters = Get-PSImplicitRemotingClientSideParameters $PSBoundParameters $True

    $scriptCmd = { & $script:InvokeCommand `
    @clientSideParameters `
    -HideComputerName `
    -Session (Get-PSImplicitRemotingSession -CommandName ‘Get-CASMailbox’) `
    -Arg (‘Get-CASMailbox’, $PSBoundParameters, $positionalArguments) `
    -Script { param($name, $boundParams, $unboundParams) & $name @boundParams @unboundParams } `
    }

    $steppablePipeline = $scriptCmd.GetSteppablePipeline($myInvocation.CommandOrigin)
    $steppablePipeline.Begin($myInvocation.ExpectingInput, $ExecutionContext)
    } catch {
    throw
    }
    }
    Process {
    try {
    $steppablePipeline.Process($_)
    } catch {
    throw
    }
    }
    End {
    try {
    $steppablePipeline.End()
    } catch {
    throw
    }
    }

    # .ForwardHelpTargetName Get-CASMailbox
    # .ForwardHelpCategory Function
    # .RemoteHelpRunspace PSSession

  4. shaik says:

    @Greg
    Thanks for the reply.

Skip to main content