question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Re-enable version number in the ".ps1" extension.

See original GitHub issue

Background: The “1” in “.ps1” stands for PowerShell 1.0. But as 2.0 is compatible with 1.0, the script file kept using the .ps1 extension without starting .ps2.

Today PowerShell is being brought to Linux and macOS. There will be more and more breaking changes in PowerShell 6.0 and later. (One possible example is removing UNIX alias.) I think it’s time to create a mechanism to avoid breaking legacy code when making “breaking changes”. One way is to re-enable the version number in the .ps1 extension.

Assume we have PowerShell 6.0 installed. When invoking a script ends with .ps6, enable all new “breaking changes”. But if it’s .ps1, keep the behavior as the old version (best effort).

We can avoid breaking changes and keep backwards compatibility for the moment, but we can’t do it forever. We should have some mechanisms to keep backwards compatibility when introducing “breaking changes” to the new version, so that we will not fear making “breaking changes”.

Of course file name extension is not the only way to mark the version of a script. We can pick up another way if it’s better.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:20 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
McAndersDKcommented, Aug 23, 2016

I don´t see it as ‘.ps1’ ever have been about PowerShell Version 1.

it dictate the structure and content of the file.

Lets say Microsoft wanted support binary compiled script files. This would not work with a ‘.ps1’ file, but it could be supported with a ‘.ps2’ file.

So as I see it, the idea is that if Microsoft for some reason needed to change the structure of a script file, they could do it by bumping the number in the extension.

1reaction
cbelleecommented, Sep 19, 2016

Jeffrey Snover explained why the .ps1 file extension was retaIned In subsequent PowerShell releases a while back. The ‘1’ denotes the current side by side version rather than the current language version. Link and excerpt follow.

https://blogs.msdn.microsoft.com/powershell/2007/11/02/ctp-versioning/

PowerShell Scripts continue to use “.PS1”. We will continue to pursue this approach until there is a major change in the CLR or .NET frameworks which force us to go side-by-side. It is at that point that we’ll go from .PS1 to .PS2 . Until then we will stay with .PS1 and everything that runs today will continue to run in new releases. You might write a .PS1 script which takes advantage of a cmdlet/feature that is only available in V2. If you send this to someone that has PS V1, it will fail “in some way and at some time”. If it uses some new syntax, it will fail at parse time (with a PARSER error) but if it uses a new command line switch – it won’t fail until it tries to run that command. This is what #REQUIRES is all about. You start your script with #REQUIRES -Version 2 And we will check version #’s and produce a precise error message If you have a #REQUIRES –VERSION 1 in your script, it will continue to run just find on PowerShell (V2) CTP because it is compatible with V1.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Powershell Set FileVersion - versioning
Basically I want to update the file versioning when I sign the code, and the code will get the file version of the...
Read more >
Using Visual Studio Code for PowerShell Development
The version number is a shortcut to the session menu requiring fewer clicks. Pinning the version number replicates the behavior of the  ......
Read more >
PowerShell editing with Visual Studio Code
You can configure the PowerShell extension to use any supported version of PowerShell installed on your machine by following these instructions.
Read more >
Why ".PS1" file extension for PS scripts?
It does stand for 1. But when they started work on version 2, they decided that instead of having it install side-by-side with...
Read more >
How to Write and Run a PowerShell Script File on ...
In the Save as dialog, choose a folder and provide a file name with the *.ps1 extension. In this example, I am using:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found