mirror of
https://github.com/zoicware/RemoveWindowsAI.git
synced 2025-12-17 07:06:29 +01:00
local machine fallback for executionpolicy fix #57
This commit is contained in:
@@ -967,11 +967,22 @@ foreach ($choice in $aipackages) {
|
||||
Reg.exe add 'HKLM\SOFTWARE\Policies\Microsoft\Windows\PowerShell' /v 'EnableScripts' /t REG_DWORD /d '1' /f >$null
|
||||
Reg.exe add 'HKLM\SOFTWARE\Policies\Microsoft\Windows\PowerShell' /v 'ExecutionPolicy' /t REG_SZ /d 'Unrestricted' /f >$null
|
||||
$Global:executionPolicyUser = $false
|
||||
$Global:executionPolicyMachine = $false
|
||||
}
|
||||
catch {
|
||||
$Global:executionPolicyUser = $true
|
||||
$Global:ogExecutionPolicy = Get-ItemPropertyValue -Path 'HKCU:\Software\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell' -Name 'ExecutionPolicy'
|
||||
Reg.exe add 'HKCU\Software\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell' /v 'ExecutionPolicy' /t REG_SZ /d 'Unrestricted' /f >$null
|
||||
try {
|
||||
$Global:ogExecutionPolicy = Get-ItemPropertyValue -Path 'HKCU:\Software\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell' -Name 'ExecutionPolicy' -ErrorAction Stop
|
||||
Reg.exe add 'HKCU\Software\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell' /v 'ExecutionPolicy' /t REG_SZ /d 'Unrestricted' /f >$null
|
||||
$Global:executionPolicyUser = $true
|
||||
$Global:executionPolicyMachine = $false
|
||||
}
|
||||
catch {
|
||||
$Global:ogExecutionPolicy = Get-ItemPropertyValue -Path 'HKLM:\Software\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell' -Name 'ExecutionPolicy'
|
||||
Reg.exe add 'HKLM\Software\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell' /v 'ExecutionPolicy' /t REG_SZ /d 'Unrestricted' /f >$null
|
||||
$Global:executionPolicyUser = $false
|
||||
$Global:executionPolicyMachine = $true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -2241,6 +2252,9 @@ else {
|
||||
if ($Global:executionPolicyUser) {
|
||||
Reg.exe add 'HKCU\Software\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell' /v 'ExecutionPolicy' /t REG_SZ /d $ogExecutionPolicy /f >$null
|
||||
}
|
||||
elseif ($Global:executionPolicyMachine) {
|
||||
Reg.exe add 'HKLM\Software\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell' /v 'ExecutionPolicy' /t REG_SZ /d $ogExecutionPolicy /f >$null
|
||||
}
|
||||
else {
|
||||
Reg.exe add 'HKLM\SOFTWARE\Policies\Microsoft\Windows\PowerShell' /v 'ExecutionPolicy' /t REG_SZ /d $ogExecutionPolicy /f >$null
|
||||
}
|
||||
@@ -2290,6 +2304,9 @@ if ($ogExecutionPolicy) {
|
||||
if ($Global:executionPolicyUser) {
|
||||
Reg.exe add 'HKCU\Software\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell' /v 'ExecutionPolicy' /t REG_SZ /d $ogExecutionPolicy /f >$null
|
||||
}
|
||||
elseif ($Global:executionPolicyMachine) {
|
||||
Reg.exe add 'HKLM\Software\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell' /v 'ExecutionPolicy' /t REG_SZ /d $ogExecutionPolicy /f >$null
|
||||
}
|
||||
else {
|
||||
Reg.exe add 'HKLM\SOFTWARE\Policies\Microsoft\Windows\PowerShell' /v 'ExecutionPolicy' /t REG_SZ /d $ogExecutionPolicy /f >$null
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user