tags:

views:

107

answers:

4

This may be a stupid question, but are the default aliases (e.g. cd) hardcoded in powershell or defined in a hidden "profile" script somewhere? I don't have any profiles set (per-user or system-wide) so I'm just wondering where the default ones come from.

A: 

Though I do not know the technical details I would say they are hardcoded and they are not configurable. They can be redefined or removed but the initial set is not under our control.

Roman Kuzmin
Which is a good thing, imho.
Joey
+2  A: 
Jay Bazuzi
Thank you (and others too) for a great explanation!
Xerion
A: 

They are hardcoded.

Shay Levy
+3  A: 

Hardcoded, but retrievable (like most things "hidden" in powershell)

PS> [Management.Automation.Runspaces.InitialSessionState].getproperty(
        "BuiltInAliases", [reflection.bindingflags]"NonPublic,Static").getvalue(
             $null, @()) | format-table -auto

Definition           Description            Options CommandType Visibility Name    PSSnapIn Module
----------           -----------            ------- ----------- ---------- ----    -------- ------
Add-Content                      ReadOnly, AllScope       Alias     Public ac
Add-PSSnapIn                     ReadOnly, AllScope       Alias     Public asnp
Clear-Content                    ReadOnly, AllScope       Alias     Public clc
Clear-Item                       ReadOnly, AllScope       Alias     Public cli
Clear-ItemProperty               ReadOnly, AllScope       Alias     Public clp
Clear-Variable                   ReadOnly, AllScope       Alias     Public clv
...

;-)

x0n
get-alias works too of course, but the above code is definitive regardless of other modules/snapins adding their own to the mix.
x0n