1

In an answer here on superuser.com, it is pointed out that gci -af is an alias for gci -File. That information is correct, and both command lines produce the same result of file listings.

However, I have not been able to find out a source of documentation where the -af alias is defined. For example, it is not defined in the primary documentation page for Get-ChildItem.

Is there another set of aliases for command line arguments when the command name itself is abbreviated, as in using gci for Get-ChildItem?

Sabuncu
  • 486
  • 4
  • 10
  • 21

3 Answers3

1

Is there another set of aliases for command line arguments when the command name itself is abbreviated, as in using gci for Get-ChildItem?

There are several alias for the Get-ChildItem cmdlet.

enter image description here

Source: Notes

However, I have not been able to find out a source of documentation where the -af alias is defined. For example, it is not defined in the primary documentation page for Get-ChildItem.

The alias for -File parameter most certainly is defined in the primary documentation page for Get-ChildItem

enter image description here

Source: Get-ChildItem

Ramhound
  • 44,080
1

Down on the parameter lists of the documentation, you can find that -af is inded documented as an alias of -File.

-File

To get a list of files, use the File parameter. You can use the Recurse parameter with File.

Type:                                              SwitchParameter

Aliases:                                           af

Position:                                          Named

Default value:                                  None

Accept pipeline input:                      False

Accept wildcard characters:            False

1

All cmdlet and parameter aliases can be seen this way:

  • # Get named aliases:
      Get-Alias |
      Out-GridView -PassThru -Title 'Available aliases'
    

    Get cmdlet / function parameter aliases:

    (Get-Command Get-ChildItem).Parameters.Values | where aliases | select Name, Aliases | Out-GridView -PassThru -Title 'Alias results for a given cmdlet or function.'

Another way of the above, but a bit different than your stated change, with the same results:

  • Function Get-CommandAlias
    {
      [CmdletBinding()]
    

    [Alias('gca')]

    Param ( [string]$CommandName )

    Get-Command $CommandName | Select-Object -expand ParameterSets | Foreach-Object { $PSItem.Parameters} | Where-Object { $PSItem.Aliases -ne $null } | Select-Object Name, Aliases -Unique | Sort-Object Name }

    gca -CommandName Get-Help

    Results:

    Name                  Aliases
    ----                  -------
    Debug                 {db}
    ErrorAction           {ea}
    ErrorVariable         {ev}
    InformationAction     {infa}
    InformationVariable   {iv}
    OutBuffer             {ob}
    OutVariable           {ov}
    PipelineVariable      {pv}
    Verbose               {vb}
    WarningAction         {wa}
    WarningVariable       {wv}
    

Yet another, before digging at parm aliases:

  • # Get a list of all commandlets for the specified name:
      Get-Command -Name '*Help*'  -CommandType Cmdlet |
      Out-GridView -PassThru -Title 'Available named cmdlet'
    

    Get-Command -CommandType Cmdlet | Where-Object { $PSItem.parameters.keys -match 'credential'} | Out-GridView -PassThru -Title 'Available cmdlets which has a specific parameter'

    Get a list of all functions:

    Get-Command -CommandType Function | Out-GridView -PassThru -Title 'Available functions'

    Get a list of all functions for the specified name:

    Get-Command -Name 'Help' -CommandType Function | Out-GridView -PassThru -Title 'Available named functions'

    Find all cmdlets / functions with a target parameter:

    Get-Command -CommandType Function | Where-Object { $PSItem.parameters.keys -match 'credential'} | Out-GridView -PassThru -Title 'Available functions which has a specific parameter'

    Get specifics for a module, cmdlet, or function:

    (Get-Command -Name Get-Help).Parameters (Get-Command -Name Get-Help).Parameters.Keys Get-help -Name Get-Help -Examples Get-help -Name Get-Help -Full Get-help -Name Get-Help -Online

    Get parameter that accepts pipeline input:

    Get-Help Get-ADUser -Parameter '' | Where-Object {$PSItem.pipelineInput -match 'true'} | Select-Object -Property ''

    Get property enums/options for a specifc cmdlet/function:

    1:

    (Get-Service | Select-Object -First 1).Status.GetType()
    [System.ServiceProcess.ServiceControllerStatus]::GetNames([System.ServiceProcess.ServiceControllerStatus])
    
    

    2:

    (Get-Service)[0].Status.GetType().GetEnumValues()
    (Get-ChildItem -Path $PWD)[0].GetType().GetMethods()
    
    

    List of all parameters that a given cmdlet supports along with a short description::

    Get-Help dir -para '*' | Format-Table Name, { $PSItem.Description[0].Text } -wrap

    List all loaded session modules and the exposed cmdlets / functions in them:

    Get-Module -Name '*' | ForEach-Object { Get-Command -Module $PSItem } | Out-GridView -PassThru -Title 'Available loaded modules and their cmdlets / functions'

    Get a list of specific cmdlets/functions in a module:

    (Get-Module -Name 'PSReadline' -All).ExportedCommands | Out-GridView -PassThru -Title "Available loaded modules and their cmdlets / functions"

JW0914
  • 9,096
postanote
  • 5,136