Skip to content

Conversation

@MaximFworks
Copy link

This is more accurate and informative.

This is more accurate and informative.
```

The `#requires` statement will prevent the script from running on the wrong version of PowerShell.
The `#requires` statement will make sure, that version of PowerShell is at least 3.0, or the script will exit with the error "ScriptRequiresUnmatchedPSVersion". You may still encounter problems if you run PowerShell 5.1 (.NET Framework) scripts on PowerShell 7+ (.NET Core).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this whole section probably needs to be rewritten in the modern era, because we should have more information here about "Windows PowerShell" (PowerShell) vs. "PowerShell" (pwsh) and should update all the examples to drop references to 3 and 4 which are basically irrelevant today.

I don't think we want to specify what the error text is though (it does not matter, may be localized, and could change). How about we just make this say:

#requires -version 5.1

This #requires statement will prevent the script from being run on a version of PowerShell older than the one specified. It does not prevent running it on newer versions, nor does it provide any compatibility mode in future versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants