windowsfunctionpowershellscriptingalias

Powershell: What's the difference between Alias and Function?


Im setting up my powershell profile to create aliases of commonly used commands. On Microsoft's documentation it says, if I want to make an alias for a command with parameters, I should make the value of the alias a Function that does that.enter image description here. However, when I type the name of the function in the command line it works just as well as an alias.

In other words, in the above picture, if I typed CD32 it would behave the same as if I typed Go in the command line

So my question is: Why do I use aliases pointing to functions when I could just have a function? Are there feature differences between the two?


Solution


  • As for whether it makes sense to define an alias for a function, if implementation of your command requires a function (due to requiring more than just a simple name mapping):