Skip to content

Update Language-Interop-and-.NET.md #189

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Best-Practices/Language-Interop-and-.NET.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ All that said, make sure you specify the version of PowerShell you wrote for by
#requires -version 3.0
```

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.


### PowerShell Supported Version

Expand Down