Last active
July 10, 2025 13:30
-
-
Save zandercodes/f00b21ec0c6ce7e917b603ed1aae0331 to your computer and use it in GitHub Desktop.
Ensure script runs under PowerShell 7.5 or higher
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ensure script runs under PowerShell 7.5 or higher | |
if ($PSVersionTable.PSVersion -lt [Version]"7.5") { | |
$pwshExe = Get-Command pwsh.exe -ErrorAction SilentlyContinue | |
if ($pwshExe -and $pwshExe.Version -ge [Version]"7.5") { | |
Write-Host "Restarting script with PowerShell 7.5 or higher..." | |
& $pwshExe.Source -File $MyInvocation.MyCommand.Path @args | |
exit | |
} else { | |
Write-Host "This script requires PowerShell 7.5 or higher." | |
exit 1 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment