set an alias for a command ( or function ) and specify parameters?

Welcome Forums General PowerShell Q&A set an alias for a command ( or function ) and specify parameters?

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

 
Keymaster
5 years, 1 month ago.

  • Author
    Posts
  • #10716

    Participant
    Points: 0
    Rank: Member

    Is it possible to set an alias for a command ( or function ) and specify parameters? For a simplified example —

    # define alias
    set-alias -name show-members -value "Get-QADGroupMember -Identity $args"

    # usage example
    show-members

    (I'm trying to do this with some custom functions I have given to users. )

    Many thanks!

  • #10719

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

    Not an alias, no. Aliases are only nicknames for commands.

    That said, there's nothing stopping you from defining a function that runs a command and uses specific parameters. That's what "help" is.

The topic ‘set an alias for a command ( or function ) and specify parameters?’ is closed to new replies.