Working Around PowerShell's Set-alias

PowerShell’s set-alias command is very limited by its apparent inability to easily accept parameters for commands that are being aliased. Those of us who are used to Linux shells where aliases such as alias ls="ls -lh" are commonplace have to wrap our heads around the fact that the ideal use case for set-alias is a only a simple one to one mapping like set-alias sql invoke-sqlcmd.

Fortunately, there’s a simple workaround:

function vehicles { invoke-sqlcmd "select * from agencyvehicle" }

Use a function instead! The syntax is concise and doesn’t come with any harmful side effects.

Edit (2010/12/02) – more logical to use a function rather than an alias to a function (duh!).

Posted on December 1, 2010 from Calgary


My name is Brandur. I'm a polyglot software engineer and part-time designer working at Heroku in San Francisco, California. I'm a Canadian expat. My name is Icelandic. Drop me a line at

Aside from technology, I'm interested in energy and how it relates to our society, travel, longboarding, muay thai, symphonic metal, and the guitar.

If you liked this article, consider finding me on Twitter.