-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.pwsh-check.ps1
30 lines (23 loc) · 1.24 KB
/
.pwsh-check.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<#PSScriptInfo
.VERSION 1.0.0
.GUID 7f63d41a-acd4-470e-9fc2-b8c99208d17d
.AUTHOR Black Duck
.COPYRIGHT Copyright 2024 Black Duck Software, Inc. All rights reserved.
.DESCRIPTION Tests PowerShell edition and version requirements.
#>
# link to PowerShell install instructions for Windows, macOS, and Linux
$powerShellInstallLink = 'https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell'
$requiredEdition = 'Core' # Windows PowerShell is unsupported
if ($PSVersionTable.PSEdition -ne $requiredEdition) {
$PSVersionTable.Keys | ForEach-Object {
Write-Host " $_`: $($PSVersionTable[$_])"
}
Write-Host "`nThis PowerShell edition ($($PSVersionTable.PSEdition)) is unsupported. You must install PowerShell Core by following the instructions at $powerShellInstallLink.`n"
Exit 2
}
# The Core PSEdition includes the SemanticVersion type, which is unavailable on Windows PowerShell
$minimumVersion = New-Object System.Management.Automation.SemanticVersion('7.0.0')
if ($PSVersionTable.PSVersion -lt $minimumVersion) {
Write-Host "This version of PowerShell ($($PSVersionTable.PSVersion)) is too old (the minimum version is $minimumVersion). Install a newer version by following the instructions at $powerShellInstallLink.`n"
Exit 3
}