Search
Free Signup | Login
Search Articles
Topics
Article List
Article Archive
Relevant Links
PowerShell PS1 - I Feel the Power But You're Ugly!
Location: BlogsRevindexPowerShell    
Posted by: revindex 8/14/2007 3:33 PM

PowerShell, the next generation of Windows command line tool, was previously known as Microsoft Shell (code-named Monad). I was intrigue and started playing with the scripts when it came out. Of course, they were called MSH scripts back then and every file carried the ".msh" extension.

Marketing Gone Overboard

The term "Microsoft Shell" was too plain and people wouldn't be able to discriminate with other shells popularized on Linux and Unix. So it was thought that by giving a stronger name would boost adoption and turn heads.

When the marketing people at Microsoft finally decided to rename Microsoft Shell to PowerShell, they also renamed the script file extension to ".ps1". Note, it's a numeric "1" character at the end of the extension and not the lowercase alphabet "L".

Why the Ugly PS1?

I was perplexed by the odd extension used, so I posted a message in protest to Microsoft while they were busy pushing out the Release Candidate. I was hoping they rename the extension to something more sensible like ".msh" or ".psh" before it goes live.

I complained for several reasons. By that time, there were already numerous scripts contributed by the community carrying the ".msh" extension. Renaming to ".ps1" would require refactoring all the script dependencies since command line files tend to be webbed together in use. At this time and even today, most powershell scripts as we know are written in Notepad so there is no quick facility to refactor names. Secondly, the odd numeric "1" could easily be confused with the letter "L" in some fonts and could lead to a potential security exploit.

Give Your Scripts a Version Number

It turns out the rename was not just a marketing ploy. It was for self-versioning purposes. Microsoft decided that scripts should automatically carry a version by virtue of its file extension. For example, the next major version will require scripts to be named with a ".ps2", ".ps3" extension and so forth.

I can imagine several benefits to have versioning. For one thing, it makes it easier to manage any backward incompatibilities between versions of the PowerShell. Scripts files are just text and don't have strong name or version information embedded unlike binary DLL or EXE so the file extension becomes a natural place to store that information.

Curiously, I've never seen this in other shells and I have yet to wait to see how this will play out in the field. So get ready, because you'll see a lot more numbered extensions coming along if this trend catches on.

Permalink |  Trackback

Comments (2)   Add Comment
Re: PowerShell PS1 - I Feel the Power But You're Ugly!    By Jeffrey Snover on 8/22/2007 12:25 AM
One of the longstanding problems with Languages is that they don't evolve nicely. We recognized that and wanted to put mechanisms in place that allowed older scripts to run side-by-side with newer scripts if we ever decided that we needed to produce a discontinuity in the language. We hope that we won't need to that but we put in this mechanism now so that everyone knew where we were going and avoid problems down the line (e.g. image what would have happened if we did .PS and then someone else grabbed .PS1 - it would be a boof-a-rama). Now everyone is on notice - at some point, we'll be using .PS2 and after that .PS3 so if you don't want to collide - don't use those extensions.

I realize that it is a bit ugly but it seemed like a small price to pay for being thoughtful about versioning and being a good citizen to the community by begin clear about where we'll end up going.

Cheers!

Jeffrey Snover [MSFT]
Windows Management Partner Architect
Visit the Windows PowerShell Team blog at: http://blogs.msdn.com/PowerShell
Visit the Windows PowerShell ScriptCenter at: http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx

Re: PowerShell PS1 - I Feel the Power But You're Ugly!    By Stephen on 8/22/2007 8:17 AM
I think you're right about staying smart and cautious on letting scripts evolve with the version number.

I would have done it differently by requiring some XML header inside the .ps file. The XML allows for a richer declaration than just version number like you have it in file extensions. You could store alias, major and minor version, attribution, copyright, etc.. all in a standard way that can be extracted by programs. The powershell engine would allow/disallow the versions it can run by reading the XML header.

There's absolutely nothing wrong mixing a bit of XML with script code. Other languages/standards have done so (HTML, XQuery, Flex, etc).

Of course, if you want it simple, you could in practice keep versioning without changing extension by naming your files like: file1.ps, file2.ps instead of file.ps1, file.ps2 (requires some level of discipline) ;)

Can't wait to see what powershell brings next !

Stephen Lim


Your name:
Title:
Comment:
Add Comment   Cancel