Skip to content

Commit

Permalink
[installer] Improve install.ps1 code (#604)
Browse files Browse the repository at this point in the history
- Remove progress bar for better performance
- Check for PowerShell x86 as it is unsupported
- Disable `KeepAlive` in connectivity check as no subsequent request are
  expected
  • Loading branch information
CamoCatX authored Sep 5, 2024
1 parent 0cc241d commit 392d76b
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,16 @@ param (
[switch]$noReboots,
[switch]$noChecks
)
$ErrorActionPreference = "Stop"
$ErrorActionPreference = 'Stop'
$ProgressPreference = 'SilentlyContinue'

# https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.localaccounts/set-localuser
if ( -not ([Environment]::Is64BitProcess)) {
Write-Host "`t[!] It seems like you are using 32 bit powershell. Exiting because some commands do not work correctly in this mode." -ForegroundColor Red
Write-Host "`t[-] Hint: Don't run powershell x86" -ForegroundColor Yellow
Start-Sleep 3
exit 1
}

# Function to test the network stack. Ping/GET requests to the resource to ensure that network stack looks good for installation
function Test-WebConnection {
Expand All @@ -94,7 +103,7 @@ function Test-WebConnection {

$response = $null
try {
$response = Invoke-WebRequest -Uri "https://$url" -UseBasicParsing
$response = Invoke-WebRequest -Uri "https://$url" -UseBasicParsing -DisableKeepAlive
}
catch {
Write-Host "`t[!] Error accessing $url. Exception: $($_.Exception.Message)`n`t[!] Check your network settings." -ForegroundColor Red
Expand Down Expand Up @@ -257,9 +266,9 @@ if (-not $noChecks.IsPresent) {
}

# Internet connectivity checks
Test-WebConnection "google.com"
Test-WebConnection "github.com"
Test-WebConnection "raw.githubusercontent.com"
Test-WebConnection 'google.com'
Test-WebConnection 'github.com'
Test-WebConnection 'raw.githubusercontent.com'

Write-Host "`t[+] Network connectivity looks good" -ForegroundColor Green

Expand Down

0 comments on commit 392d76b

Please sign in to comment.