Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added improvements to reduce errors and such #604

Merged
merged 3 commits into from
Sep 5, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the progress bar is a nice improvement! ✨


# 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As powershell x86 is not working at the moment, I think adding this code is a good idea. But on the long-term, is there a reason why we would want to support powershell x86 (we would need to find alternative implementations for the used function(s))? 🤔 @mandiant/vms opinions?

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
Copy link
Member

@Ana06 Ana06 Aug 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice improvement, this function is only used to test the internet connection so we do not need a persistent connection to the server as there are not subsequent requests. 👍

}
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 'microsoft.com'
Ana06 marked this conversation as resolved.
Show resolved Hide resolved
CamoCatX marked this conversation as resolved.
Show resolved Hide resolved
Test-WebConnection 'github.com'
Test-WebConnection 'google.com'

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

Expand Down