-
Notifications
You must be signed in to change notification settings - Fork 949
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 { | ||
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
@@ -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 | ||
|
||
|
There was a problem hiding this comment.
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! ✨