PowerShell has designed to be used as both a scripting language and an interactive command line tool. This is excellent planning and the fact that you can work interactively in this way makes developing and testing scripts a whole lot easier. The fact that you can use aliases for the cmdlet names can make working interactively even easier as it cuts down the typing.
However, the drawback is when those highly aliased commands (they can look like a piece of encrypted text rather than a readable script) are then saved in a script file for re-use or posted on the net for others to access. They take an awful lot more work to understand than the same script written with the full names. Newcomers to PowerShell especially find it very difficult to undestand these highly aliased scripts and I have been told by people that it has put them off PowerShell.
Please, if you are posting code or creating script files for the use of others, consider the people trying to learn PowerShell and make it easy to read. Also many experienced PowerShell users create their own aliases – use of those can really confuse people who haven’t defined the same aliases.
While I’ve been writing this I was beginning to think about a script that parses a line of PowerShell and unaliases the code. Might look in to that tomorrow…….
Very good idea. When I was first exposed to powershell, it drove me crazy looking at a script with the % in the middle of it. It wasn’t explained anywhere.
Please if you have the time see what you can come up with for undoing the aliasing. I have thought about this a couple of times but the time has never been available and you will do it much more justice.
The look of many online PowerShell examples has also been said to me more than once to have been the off putting factor by several peolpe especially with ‘private’ aliases that render the script unusable on everyone elses system.