From 94e5c95d57b791207875289e066fa05359229932 Mon Sep 17 00:00:00 2001 From: Raphire <9938813+Raphire@users.noreply.github.com> Date: Mon, 9 Mar 2026 23:21:22 +0100 Subject: [PATCH] Remove Powershell 7 modules from path to prevent module loading issues in the script --- Scripts/Get.ps1 | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Scripts/Get.ps1 b/Scripts/Get.ps1 index d147708..a3cba0d 100644 --- a/Scripts/Get.ps1 +++ b/Scripts/Get.ps1 @@ -167,16 +167,14 @@ else { $windowStyle = "Normal" } -# Use powershell 7 to launch the script if the current environment is powershell 7, otherwise use powershell 5.1 +# Remove Powershell 7 modules from path to prevent module loading issues in the script if ($PSVersionTable.PSVersion.Major -ge 7) { - $powershellExe = "pwsh.exe" -} -else { - $powershellExe = "powershell.exe" + $NewPSModulePath = $env:PSModulePath -split ';' | Where-Object -FilterScript { $_ -like '*WindowsPowerShell*' } + $env:PSModulePath = $NewPSModulePath -join ';' } # Run Win11Debloat script with the provided arguments -$debloatProcess = Start-Process $powershellExe -WindowStyle $windowStyle -PassThru -ArgumentList "-executionpolicy bypass -File $env:TEMP\Win11Debloat\Win11Debloat.ps1 $arguments" -Verb RunAs +$debloatProcess = Start-Process powershell.exe -WindowStyle $windowStyle -PassThru -ArgumentList "-executionpolicy bypass -File $env:TEMP\Win11Debloat\Win11Debloat.ps1 $arguments" -Verb RunAs # Wait for the process to finish before continuing if ($null -ne $debloatProcess) {