Launch main script using pwsh.exe when Get.ps1 is run in Powershell 7

This commit is contained in:
Raphire
2026-03-09 22:49:07 +01:00
parent 18823c4a80
commit 992c80bc1e
2 changed files with 9 additions and 3 deletions

View File

@@ -166,8 +166,16 @@ else {
$windowStyle = "Normal" $windowStyle = "Normal"
} }
# Use powershell 7 to launch the script if the current environment is powershell 7, otherwise use powershell 5.1
if ($PSVersionTable.PSVersion.Major -ge 7) {
$powershellExe = "pwsh.exe"
}
else {
$powershellExe = "powershell.exe"
}
# Run Win11Debloat script with the provided arguments # Run Win11Debloat script with the provided arguments
$debloatProcess = Start-Process powershell.exe -WindowStyle $windowStyle -PassThru -ArgumentList "-executionpolicy bypass -File $env:TEMP\Win11Debloat\Win11Debloat.ps1 $arguments" -Verb RunAs $debloatProcess = Start-Process $powershellExe -WindowStyle $windowStyle -PassThru -ArgumentList "-executionpolicy bypass -File $env:TEMP\Win11Debloat\Win11Debloat.ps1 $arguments" -Verb RunAs
# Wait for the process to finish before continuing # Wait for the process to finish before continuing
if ($null -ne $debloatProcess) { if ($null -ne $debloatProcess) {

View File

@@ -101,8 +101,6 @@ param (
Import-Module Microsoft.PowerShell.Security -SkipEditionCheck
# Define script-level variables & paths # Define script-level variables & paths
$script:Version = "2026.03.07" $script:Version = "2026.03.07"
$script:AppsListFilePath = "$PSScriptRoot/Config/Apps.json" $script:AppsListFilePath = "$PSScriptRoot/Config/Apps.json"