mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 12:10:49 +00:00
Powershell: check if the executionpolicy allow to run safe-chain
This commit is contained in:
parent
611fe8007f
commit
c765438e63
1 changed files with 24 additions and 1 deletions
|
|
@ -31,6 +31,28 @@ function Write-Error-Custom {
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Check if the PowerShell execution policy allows script execution
|
||||||
|
function Test-ExecutionPolicy {
|
||||||
|
$policy = Get-ExecutionPolicy
|
||||||
|
$acceptablePolicies = @('RemoteSigned', 'Unrestricted', 'Bypass')
|
||||||
|
return $acceptablePolicies -contains $policy
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (-not (Test-ExecutionPolicy)) {
|
||||||
|
$currentPolicy = Get-ExecutionPolicy
|
||||||
|
Write-Error-Custom @"
|
||||||
|
PowerShell execution policy is set to '$currentPolicy', which prevents safe-chain from running.
|
||||||
|
|
||||||
|
The execution policy must be at least 'RemoteSigned' to allow safe-chain's initialization script to run.
|
||||||
|
|
||||||
|
To fix this, open PowerShell as Administrator and run:
|
||||||
|
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
|
||||||
|
|
||||||
|
Then restart this installation.
|
||||||
|
"@
|
||||||
|
}
|
||||||
|
|
||||||
# Get currently installed version of safe-chain
|
# Get currently installed version of safe-chain
|
||||||
function Get-InstalledVersion {
|
function Get-InstalledVersion {
|
||||||
# Check if safe-chain command exists
|
# Check if safe-chain command exists
|
||||||
|
|
@ -157,7 +179,8 @@ function Install-SafeChain {
|
||||||
Write-Warn ""
|
Write-Warn ""
|
||||||
if ($ci) {
|
if ($ci) {
|
||||||
Write-Warn " iex `"& { `$(iwr 'https://github.com/AikidoSec/safe-chain/releases/download/$env:SAFE_CHAIN_VERSION/install-safe-chain.ps1' -UseBasicParsing) } -ci`""
|
Write-Warn " iex `"& { `$(iwr 'https://github.com/AikidoSec/safe-chain/releases/download/$env:SAFE_CHAIN_VERSION/install-safe-chain.ps1' -UseBasicParsing) } -ci`""
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
Write-Warn " iex (iwr `"https://github.com/AikidoSec/safe-chain/releases/download/$env:SAFE_CHAIN_VERSION/install-safe-chain.ps1`" -UseBasicParsing)"
|
Write-Warn " iex (iwr `"https://github.com/AikidoSec/safe-chain/releases/download/$env:SAFE_CHAIN_VERSION/install-safe-chain.ps1`" -UseBasicParsing)"
|
||||||
}
|
}
|
||||||
Write-Warn ""
|
Write-Warn ""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue