mirror of
https://github.com/ntdevlabs/tiny11builder.git
synced 2025-03-13 02:05:29 +00:00
fix: change disallowing ExecutionPolicy
- Add AllSigned, Undefined for consideration which also prevent script from running
This commit is contained in:
parent
49dac34d87
commit
b0750f317c
@ -1,12 +1,14 @@
|
|||||||
# Enable debugging
|
# Enable debugging
|
||||||
Set-PSDebug -Trace 1
|
Set-PSDebug -Trace 1
|
||||||
|
|
||||||
# Check if PowerShell execution is restricted
|
# Check if PowerShell execution is Restricted or AllSigned or Undefined
|
||||||
if ((Get-ExecutionPolicy) -eq 'Restricted') {
|
$needchange = @("AllSigned", "Restricted", "Undefined")
|
||||||
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)"
|
$curpolicy = Get-ExecutionPolicy
|
||||||
|
if ($curpolicy -in $needchange) {
|
||||||
|
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)"
|
||||||
$response = Read-Host
|
$response = Read-Host
|
||||||
if ($response -eq 'yes') {
|
if ($response -eq 'yes') {
|
||||||
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Confirm:$false
|
Set-ExecutionPolicy RemoteSigned -Scope Process -Confirm:$false
|
||||||
} else {
|
} else {
|
||||||
Write-Host "The script cannot be run without changing the execution policy. Exiting..."
|
Write-Host "The script cannot be run without changing the execution policy. Exiting..."
|
||||||
exit
|
exit
|
||||||
|
@ -14,12 +14,14 @@ if (-not $ScratchDisk) {
|
|||||||
|
|
||||||
Write-Output "Scratch disk set to $ScratchDisk"
|
Write-Output "Scratch disk set to $ScratchDisk"
|
||||||
|
|
||||||
# Check if PowerShell execution is restricted
|
# Check if PowerShell execution is Restricted or AllSigned or Undefined
|
||||||
if ((Get-ExecutionPolicy) -eq 'Restricted') {
|
$needchange = @("AllSigned", "Restricted", "Undefined")
|
||||||
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)"
|
$curpolicy = Get-ExecutionPolicy
|
||||||
|
if ($curpolicy -in $needchange) {
|
||||||
|
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)"
|
||||||
$response = Read-Host
|
$response = Read-Host
|
||||||
if ($response -eq 'yes') {
|
if ($response -eq 'yes') {
|
||||||
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Confirm:$false
|
Set-ExecutionPolicy RemoteSigned -Scope Process -Confirm:$false
|
||||||
} else {
|
} else {
|
||||||
Write-Host "The script cannot be run without changing the execution policy. Exiting..."
|
Write-Host "The script cannot be run without changing the execution policy. Exiting..."
|
||||||
exit
|
exit
|
||||||
|
Loading…
Reference in New Issue
Block a user