Commit 7a0726ce authored by myishay's avatar myishay
Browse files

fix: check execution policy + require Powershell version >=5

parent 934c66bb
Showing with 20 additions and 2 deletions
+20 -2
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
#Requires -Version 5
$old_erroractionpreference = $erroractionpreference
$erroractionpreference = 'stop' # quit if anything goes wrong
if (($PSVersionTable.PSVersion.Major) -lt 5) {
Write-Output "PowerShell 5 or later is required to run Datree."
Write-Output "Upgrade PowerShell: https://docs.microsoft.com/en-us/powershell/scripting/setup/installing-windows-powershell"
break
}
# show notification to change execution policy:
$allowedExecutionPolicy = @('Unrestricted', 'RemoteSigned', 'ByPass')
if ((Get-ExecutionPolicy).ToString() -notin $allowedExecutionPolicy) {
Write-Output "PowerShell requires an execution policy in [$($allowedExecutionPolicy -join ", ")] to run Datree."
Write-Output "For example, to set the execution policy to 'RemoteSigned' please run :"
Write-Output "'Set-ExecutionPolicy RemoteSigned -scope CurrentUser'"
break
}
$DOWNLOAD_URL = (Invoke-WebRequest -Uri 'https://api.github.com/repos/datreeio/datree/releases/latest' | select-string -Pattern 'https://github.com/datreeio/datree/releases/download/\d+\.\d+\.\d+/datree-cli_\d+\.\d+\.\d+_windows_x86_64.zip').Matches.Value
$OUTPUT_BASENAME = "datree-latest"
......@@ -21,7 +39,7 @@ Remove-Item $OUTPUT_BASENAME_WITH_POSTFIX
$dotDatreePath = "$home/.datree"
mkdir -Force $dotDatreePath | Out-Null
$k8sDemoPath = Join-Path "$dotDatreePath" "k8s-demo.yaml"
$k8sDemoPath = Join-Path "$dotDatreePath" "k8s-demo.yaml"
Invoke-WebRequest -Uri "https://get.datree.io/k8s-demo.yaml" -OutFile $k8sDemoPath
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment