Skip to content
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

Merged

Conversation

michaeljsXu
Copy link
Contributor

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

powershell_error
Confirmed that attempting to Import-Module .\tools\OpenConsole.psm1 throws an error on Powershell 5.

PR Checklist

@microsoft-github-policy-service microsoft-github-policy-service bot added Issue-Task It's a feature request, but it doesn't really need a major design. Area-CodeHealth Issues related to code cleanliness, linting, rules, warnings, errors, static analysis, etc. Product-Meta The product is the management of the products. labels Oct 10, 2024
Comment on lines 1 to 5
# 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
}
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

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.

Copy link
Member

@lhecker lhecker left a comment

Choose a reason for hiding this comment

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

Thanks!

Copy link
Member

@DHowett DHowett left a comment

Choose a reason for hiding this comment

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

Hey, thanks for doing this! I'm actually not sure the module DOES require PS 7 - I just gave it a shot on 5.1 and it works great...

image

@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Oct 10, 2024
@DHowett
Copy link
Member

DHowett commented Oct 10, 2024

Zadjii-msft's original assessment may have been wrong here

@michaeljsXu
Copy link
Contributor Author

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

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs-Attention The core contributors need to come back around and look at this ASAP. and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something labels Oct 11, 2024
Copy link
Member

@DHowett DHowett left a 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

@DHowett DHowett merged commit 494bc5b into microsoft:main Oct 11, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-CodeHealth Issues related to code cleanliness, linting, rules, warnings, errors, static analysis, etc. Issue-Task It's a feature request, but it doesn't really need a major design. Needs-Attention The core contributors need to come back around and look at this ASAP. Product-Meta The product is the management of the products.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Importing the OpenConsole.psm1 module should display an error message when used on Windows PowerShell 5
3 participants