-
Notifications
You must be signed in to change notification settings - Fork 8.6k
OpenConsole.psm1 PSVersion check #18021
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
OpenConsole.psm1 PSVersion check #18021
Conversation
tools/OpenConsole.psm1
Outdated
# throw error if Powershell version is lower than 7 | ||
if ($PSVersionTable.PSVersion.Major -lt 7) { | ||
throw "This script requires PowerShell 7 or higher. Current version: $($PSVersionTable.PSVersion)" | ||
exit | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use #Requires -Version 7
? https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_requires
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, I changed it to using #Requires.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Zadjii-msft's original assessment may have been wrong here |
Just to double check, is the Powershell 7 requirement in prerequisites for a different part of the project? I thought maybe something would require it along the way in OpenConsole |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You know what? You’re totally right. Even though this module doesn’t require PowerShell 7, the rest of the build process absolutely will. Having this check in the beginning will stop people from getting errors later.
thank you
We started requiring PowerShell 7+ in #18021 We did not update the code formatting task.
Summary of the Pull Request
Added a check in OpenConsole.psm1 to throw an error if the Powershell version is <7.
References and Relevant Issues
Detailed Description of the Pull Request / Additional comments
Validation Steps Performed
Confirmed that attempting to
Import-Module .\tools\OpenConsole.psm1
throws an error on Powershell 5.PR Checklist
OpenConsole.psm1
module should display an error message when used on Windows PowerShell 5 #17505