locked
Why is the 'Get' verb part of commands optional? RRS feed

  • Question

  • In PowerShell, why is the 'Get' verb part of a command optional? In other words, the 'Get-Foo' can be run by typing 'Foo' only.


    For example, open a command window and type:

        > Get-Date

        Tuesday, October 3, 2017 4:22:23 PM

    Then just type 'Date':

        > Date

    Tuesday, October 3, 2017 4:23:01 PM


    This seems to apply to most commands starting with the 'Get-' verb, but not for other verbs.
    I don't see any aliases. Why does the command shell automatically run without the 'Get' verb?

    Tuesday, October 3, 2017 11:48 PM

Answers

  • TJKennedy is correct; the "Get" verb is implicit if not specified; see here:

    https://github.com/PowerShell/PowerShell/issues/3987

    It's an odd feature. I'm with Jason that they should remove this "feature" as it seems to cause more confusion than anything else.


    -- Bill Stewart [Bill_Stewart]

    • Proposed as answer by BOfH-666 Wednesday, October 4, 2017 7:41 PM
    • Marked as answer by Richard MuellerMVP Wednesday, October 11, 2017 12:02 PM
    Wednesday, October 4, 2017 2:00 PM

All replies

  • There is no "Date" command in PowerShell.  Do the following.

    get-command get-date
    get-command date

    Do this for any command that you think can be used both ways.


    \_(ツ)_/

    Wednesday, October 4, 2017 12:33 AM
  • TJKennedy is correct; the "Get" verb is implicit if not specified; see here:

    https://github.com/PowerShell/PowerShell/issues/3987

    It's an odd feature. I'm with Jason that they should remove this "feature" as it seems to cause more confusion than anything else.


    -- Bill Stewart [Bill_Stewart]

    • Proposed as answer by BOfH-666 Wednesday, October 4, 2017 7:41 PM
    • Marked as answer by Richard MuellerMVP Wednesday, October 11, 2017 12:02 PM
    Wednesday, October 4, 2017 2:00 PM
  • Example:

    Help Help


    Richard Mueller - MVP Enterprise Mobility (Identity and Access)

    Wednesday, October 11, 2017 12:05 PM