PowerTip: Find PowerShell Canonical Aliases

Summary: Find Windows PowerShell aliases that are read-only and available in all scopes.

Hey, Scripting Guy! Question How can I produce a list of Windows PowerShell aliases that are read-only and are available in
           all Windows PowerShell scopes?

Hey, Scripting Guy! Answer Use the Get-Alias cmdlet to produce a list of aliases, filter on aliases that have an option of read-only,
           and select the name, definition, and options:

Get-Alias | Where options -match 'readonly' | select name, definition, options

Comments (2)

  1. Dong Ki, Kim says:

    I think that the right answer is as follows in case the alias is not in all scope but in readonly state.
    if the scope of all readonly aliases is "AllScope", your answer is right albeit too many ToString method is used.

    $allScopeAndReadOnly = [System.Management.Automation.ScopedItemOptions]::AllScope -bor [System.Management.Automation.ScopedItemOptions]::ReadOnly

    Get-Alias | where { ($_.Options -band $allScopeAndReadOnly) -eq $allScopeAndReadOnly } | select name, definition, options