Skip to content

Commit b0750f3

Browse files
committed
fix: change disallowing ExecutionPolicy
- Add AllSigned, Undefined for consideration which also prevent script from running
1 parent 49dac34 commit b0750f3

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

tiny11Coremaker.ps1

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
# Enable debugging
22
Set-PSDebug -Trace 1
33

4-
# Check if PowerShell execution is restricted
5-
if ((Get-ExecutionPolicy) -eq 'Restricted') {
6-
Write-Host "Your current PowerShell Execution Policy is set to Restricted, which prevents scripts from running. Do you want to change it to RemoteSigned? (yes/no)"
4+
# Check if PowerShell execution is Restricted or AllSigned or Undefined
5+
$needchange = @("AllSigned", "Restricted", "Undefined")
6+
$curpolicy = Get-ExecutionPolicy
7+
if ($curpolicy -in $needchange) {
8+
Write-Host "Your current PowerShell Execution Policy is set to $curpolicy, which prevents scripts from running. Do you want to change it to RemoteSigned? (yes/no)"
79
$response = Read-Host
810
if ($response -eq 'yes') {
9-
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Confirm:$false
11+
Set-ExecutionPolicy RemoteSigned -Scope Process -Confirm:$false
1012
} else {
1113
Write-Host "The script cannot be run without changing the execution policy. Exiting..."
1214
exit

tiny11maker.ps1

+6-4
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@ if (-not $ScratchDisk) {
1414

1515
Write-Output "Scratch disk set to $ScratchDisk"
1616

17-
# Check if PowerShell execution is restricted
18-
if ((Get-ExecutionPolicy) -eq 'Restricted') {
19-
Write-Host "Your current PowerShell Execution Policy is set to Restricted, which prevents scripts from running. Do you want to change it to RemoteSigned? (yes/no)"
17+
# Check if PowerShell execution is Restricted or AllSigned or Undefined
18+
$needchange = @("AllSigned", "Restricted", "Undefined")
19+
$curpolicy = Get-ExecutionPolicy
20+
if ($curpolicy -in $needchange) {
21+
Write-Host "Your current PowerShell Execution Policy is set to $curpolicy, which prevents scripts from running. Do you want to change it to RemoteSigned? (yes/no)"
2022
$response = Read-Host
2123
if ($response -eq 'yes') {
22-
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Confirm:$false
24+
Set-ExecutionPolicy RemoteSigned -Scope Process -Confirm:$false
2325
} else {
2426
Write-Host "The script cannot be run without changing the execution policy. Exiting..."
2527
exit

0 commit comments

Comments
 (0)