Finding Aliases for Parameters in PowerShell

Going concise as possible WAS bad practice at one stage!

Words: 443

Time to read: around 3 minutes

I’ve been wanting to get into ChatOps for a while now and so when Warren Frame’s ( blog | twitter ) post on PoshBot Usability popped up on my post feed, I dived into it.

One of the practices that Warren mentions is to “[…] Keep it short.”

Verbosity is king in PowerShell. With no tab completion to help discovery and spelling? Keep it short! Reserve single character aliases for your most popular commands and parameters. Expand as needed. Again, you can always leave the actual command name in a PowerShell Verb-Noun format, but do use short aliases for chat.

Don’t forget parameters! Want to specify properties? -p is a nice shorthand for -property, for example.

I’ve highlighted the sentence that popped out for me.

Function Aliases:

Now I knew that you could give a function an alias. I even do that for one of the functions I created and use; the one that tells me how long a video lasts if I watch at different speeds.

In case you were wondering, the specific section is this bit; I’ve added a comment # <-- where it can be found

That, however, is to give the entire function an alias. In this case, rather than type out Get-VideoPlayBackTime -Minutes etc, I can just type video -minutes etc.
Handy when you’re running it sporadically at the command line.

Warren mentions parameter aliases though and gives great examples in his other post about getting started with PoshBot.

Again, look for the # <--

This got me thinking, how do we find aliases for parameters?

Parameter Aliases:

I tried looking in the help file but, taking ConvertTo-Csv as an example, there’s no mention of an alias that I can see in there (Get-Help -Name ConvertTo-Csv -Full).

So time to whip up a function 🙂

Running: Get-ParameterAlias -Command ConvertTo-Csv

NoTypeInformation = NTI ???

Sweet as!

I wonder if it works on multiple commands, say anything to do with CSVs?

Running: Get-ParameterAlias -Command *CSV


Since I’d mainly be thinking of using ChatOps on databases, and I mainly use the dbatools module, does it work on that?

Running: Get-ParameterAlias -Command (Get-Command -Module dbatools -CommandType Function) | Select-Object -First 50


Still a bit long for ChatOps but they’re there, this works, and I can always create a pull request on Github for them!


Yes, I know the function isn’t finished; no comment based help, verbose writing, or examples; and I’m painfully aware that a function about finding parameter aliases doesn’t have any parameter aliases itself. 😐

But hey! Feel free to help mature this out over on Github and help out. That goes for creating issues and pull requests on dbatools as well!

Author: Shane O'Neill

DBA, T-SQL and PowerShell admirer, Food, Coffee, Whiskey (not necessarily in that order)...

One thought on “Finding Aliases for Parameters in PowerShell”

What's your opinion?

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s