Getting Parameter Properties

Welcome Forums General PowerShell Q&A Getting Parameter Properties

This topic contains 1 reply, has 2 voices, and was last updated by

 
Keymaster
2 years, 3 months ago.

  • Author
    Posts
  • #55055

    Participant
    Points: 0
    Rank: Member

    I came across a cmdlet that has a ton of parameters. Instead of reading the help to determine the properties of each parameter, I'd like to filter properties in the console. As an example, I'd like to return parameters of a cmdlet that are only mandatory.

    How can I do that?

    Was thinking something on the order of what's shown below, but I'm not able to find what I'm looking for – and neither is Bono.

    Get-Command New-SelfSignedCertificate | 
    select-object -ExpandProperty Parameters | 
    where { $_.Mandatory -eq $true }
    

    I made up the property at the end of the pipeline so that my question would make more sense.

  • #55062

    Keymaster
    Points: 1,785
    Helping HandTeam Member
    Rank: Community Hero

    It's "IsMandatory."

    Get-Command Get-ChildItem | Format-Custom *
    

    Is probably the easiest way to see the object structure, short of using Lee Holmes' Show-Object command from the powershellcookbook module.

The topic ‘Getting Parameter Properties’ is closed to new replies.