mirror of
https://github.com/Raphire/Win11Debloat.git
synced 2026-04-03 14:06:27 +00:00
Remove Powershell 7 modules from path to prevent module loading issues in the script
This commit is contained in:
@@ -167,16 +167,14 @@ else {
|
|||||||
$windowStyle = "Normal"
|
$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) {
|
if ($PSVersionTable.PSVersion.Major -ge 7) {
|
||||||
$powershellExe = "pwsh.exe"
|
$NewPSModulePath = $env:PSModulePath -split ';' | Where-Object -FilterScript { $_ -like '*WindowsPowerShell*' }
|
||||||
}
|
$env:PSModulePath = $NewPSModulePath -join ';'
|
||||||
else {
|
|
||||||
$powershellExe = "powershell.exe"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Run Win11Debloat script with the provided arguments
|
# 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
|
# Wait for the process to finish before continuing
|
||||||
if ($null -ne $debloatProcess) {
|
if ($null -ne $debloatProcess) {
|
||||||
|
|||||||
Reference in New Issue
Block a user