huntresslabs / deployment-scripts

RMM deployment scripts for Huntress
37 stars 33 forks source link

If powershell version is too low, powershell install script errors out #1

Closed SecOpsWarrior closed 4 years ago

SecOpsWarrior commented 5 years ago

If powershell version is too low, for example 2, the script errors out and it seems to be giving a network error. Suggest checking version and then printing out specific error message if powershell version is too low.

Current error message:

[11/17/18 02:22:39] Exception calling "DownloadFile" with "2" argument(s): "The underlying connection was closed: An unexpected error occurred on a send." [11/17/18 02:22:39] Failed to download the Huntress Installer from https://huntress.io/download/*redacted*/HuntressAgent.exe [11/17/18 02:22:39] Verify you set the AccountKey variable to your account secret key.

jdferrell3 commented 5 years ago

@jallen202020 I wasn't able to recreate the exact error, but I was able to generate similar errors. I do not believe the issue is related to the Powershell version. On a host with Powershell 2.0 I got similar errors when the account key was invalid and when the hosts's network connection was disabled. The Powershell exception always includes the "Exception calling "DownloadFile" with "2" argument(s): ..." with the actual error:

[11/28/18 16:20:42] Exception calling "DownloadFile" with "2" argument(s): "The remote server returned an error: (404) Not Found."

[11/28/18 16:21:45] Exception calling "DownloadFile" with "2" argument(s): "The remote name could not be resolved: 'huntress.io'"


Windows PowerShell
Copyright (C) 2009 Microsoft Corporation. All rights reserved.

PS C:\Users\administrator> $PSVersionTable.PSVersion

Major  Minor  Build  Revision
-----  -----  -----  --------
2      0      -1     -1

PS C:\Users\administrator> exit

C:\Users\administrator>cd Desktop

C:\Users\administrator\Desktop>powershell -executionpolicy bypass -f ./InstallHuntress.powershellv1.ps1
[11/28/18 16:20:42] OrganizationKey:  org
[11/28/18 16:20:42] Exception calling "DownloadFile" with "2" argument(s): "The remote server returned an error: (404) Not Found."
[11/28/18 16:20:42] Failed to download the Huntress Installer from https://huntress.io/download/12345678901234567890123456789012/HuntressAgent.exe
[11/28/18 16:20:42] Verify you set the AccountKey variable to your account secret key.
[11/28/18 16:20:42] Script Failed!

C:\Users\administrator\Desktop>powershell -executionpolicy bypass -f ./InstallHuntress.powershellv1.ps1
[11/28/18 16:21:45] OrganizationKey:  org
[11/28/18 16:21:45] Exception calling "DownloadFile" with "2" argument(s): "The
remote name could not be resolved: 'huntress.io'"
[11/28/18 16:21:45] Failed to download the Huntress Installer from https://huntress.io/download/12345678901234567890123456789012/HuntressAgent.exe
[11/28/18 16:21:45] Verify you set the AccountKey variable to your account secret key.
[11/28/18 16:21:45] Script Failed!```
SecOpsWarrior commented 5 years ago

Hmmm. I can guarantee the account key was correct because I checked that literally 10 times or more before moving on. Then I updated the powershell version and we ran the exact same script and it worked totally fine.

Did you try hard coding the key in the file as well as running it as a tag in the command line? I was running it as hard-coded in the file and did not test running it as a tag in the command line.


From: jdferrell3 notifications@github.com Sent: Wednesday, November 28, 2018 3:55 PM To: huntresslabs/deployment-scripts Cc: jallen202020; Mention Subject: Re: [huntresslabs/deployment-scripts] If powershell version is too low, powershell install script errors out (#1)

@jallen202020https://github.com/jallen202020 I wasn't able to recreate the exact error, but I was able to generate similar errors. I do not believe the issue is related to the Powershell version. On a host with Powershell 2.0 I got similar errors when the account key was invalid and when the hosts's network connection was disabled. The Powershell exception always includes the "Exception calling "DownloadFile" with "2" argument(s): ..." with the actual error:

`C:\Users\administrator>powershell Windows PowerShell Copyright (C) 2009 Microsoft Corporation. All rights reserved.

PS C:\Users\administrator> $PSVersionTable.PSVersion

Major Minor Build Revision


2 0 -1 -1

PS C:\Users\administrator> exit

C:\Users\administrator>cd Desktop

C:\Users\administrator\Desktop>powershell -executionpolicy bypass -f ./InstallHuntress.powershellv1.ps1 [11/28/18 16:20:42] OrganizationKey: org [11/28/18 16:20:42] Exception calling "DownloadFile" with "2" argument(s): "The remote server returned an error: (404) Not Found." [11/28/18 16:20:42] Failed to download the Huntress Installer from https://huntress.io/download/12345678901234567890123456789012/HuntressAgent.exe [11/28/18 16:20:42] Verify you set the AccountKey variable to your account secret key. [11/28/18 16:20:42] Script Failed!

C:\Users\administrator\Desktop>powershell -executionpolicy bypass -f ./InstallHuntress.powershellv1.ps1 [11/28/18 16:21:45] OrganizationKey: org [11/28/18 16:21:45] Exception calling "DownloadFile" with "2" argument(s): "The remote name could not be resolved: 'huntress.io'" [11/28/18 16:21:45] Failed to download the Huntress Installer from https://huntress.io/download/12345678901234567890123456789012/HuntressAgent.exe [11/28/18 16:21:45] Verify you set the AccountKey variable to your account secret key. [11/28/18 16:21:45] Script Failed!`

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/huntresslabs/deployment-scripts/issues/1#issuecomment-442619712, or mute the threadhttps://github.com/notifications/unsubscribe-auth/APaDDNm7tciTp5HSBVFoU1baXF1pkQwLks5uzwZggaJpZM4YnV7n.