I’ve always said that if you want to learn something really well, teach it to someone. I’ve been doing internal PowerShell training for several years at my company. I’m very grateful for the opportunity for a number of reasons, but in this post I’m going to call out how something I learned in a recent trip to our San Diego office.
When I’m starting to talk about cmdlets, I usually use get-childitem for the simple reason that almost everyone knows what the DOS DIR command does. It gives us a point of reference to compare and contrast cmdlets with.
I mentioned the -Recurse switch and explained that it was analogous to the /S switch in DIR, but one person in the class didn’t quite get the context switch. When he did one of the examples, he tried get-childitem -s. I told him that he needed to use -Recurse, to which he replied “But it works!”.
I always keep a pad of paper when I’m teaching so I can write down anything puzzling (it happens in almost every class). When the class took a break, I opened a fresh PowerShell session and tried it.
Of course, it worked.
Now, to determine why it worked.
First of all, I thought that parameter disambiguation would have been a problem. because of the -System parameter. That wasn’t a problem.
Then, I realized that the PowerShell team must have included a “legacy alias” for the -Recurse parameter, similar to how they include cmdlet aliases to ease the transition from DOS or *NIX (dir, ls, ps, cat, etc.). I don’t think I’ve ever heard anyone mention legacy aliases for parameters, though.
PowerShell easily verifies that this is the case:
Of course, I verified this on my work computer. As I sit here writing on my home laptop, it didn’t list any aliases until I updated help. Blogging is a lot like teaching in that you’re bound to find surprises whenever you try to explain something.
Anyway, this was a fun discovery for me.
Can you think of any other parameter aliases that are there for legacy reasons? I might have to try to work up a script to find candidates.
Let me know what you think in the comments.