Skip to content

Commit

Permalink
revert
Browse files Browse the repository at this point in the history
  • Loading branch information
cameron-huntress committed Dec 1, 2023
1 parent 6663b38 commit bec5a79
Showing 1 changed file with 83 additions and 0 deletions.
83 changes: 83 additions & 0 deletions Datto-RMM/scripts/InstallHuntress.dattormm.comstore.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<<<<<<< HEAD
<<<<<<< HEAD
=======
=======
>>>>>>> parent of 0c29984 (Update Datto RMM script to latest PoSh v2)
# Copyright (c) 2023 Huntress Labs, Inc.
# All rights reserved.
#
Expand Down Expand Up @@ -40,7 +43,15 @@ param (
)


<<<<<<< HEAD
# The account key should be stored in the DattoRMM account variable HUNTRESS_ACCOUNT_KEY
=======
##############################################################################
## Begin user modified variables
##############################################################################

# Replace __ACCOUNT_KEY__ with your account secret key (from your Huntress portal's "download agent" section)
>>>>>>> parent of 0c29984 (Update Datto RMM script to latest PoSh v2)
$AccountKey = "__ACCOUNT_KEY__"
if ($env:HUNTRESS_ACCOUNT_KEY) {
$AccountKey = $env:HUNTRESS_ACCOUNT_KEY
Expand Down Expand Up @@ -70,7 +81,11 @@ $estimatedSpaceNeeded = 200111222
##############################################################################

# These are used by the Huntress support team when troubleshooting.
<<<<<<< HEAD
$ScriptVersion = "Version 2, major revision 8, 2023 Jul 24, "
=======
$ScriptVersion = "Version 2, major revision 7, 2023 May 1, "
>>>>>>> parent of 0c29984 (Update Datto RMM script to latest PoSh v2)
$ScriptType = "DattoRMM"

# variables used throughout this script
Expand Down Expand Up @@ -122,6 +137,13 @@ if ( ! [string]::IsNullOrEmpty($orgkey) ) {
$OrganizationKey = $orgkey
}

<<<<<<< HEAD
=======
# Check for tags specified on the command line.
if ( ! [string]::IsNullOrEmpty($tags) ) {
$TagsKey = $tags
}
>>>>>>> parent of 0c29984 (Update Datto RMM script to latest PoSh v2)

# pick the appropriate file to download based on the OS version
if ($LegacyCommandsRequired -eq $true) {
Expand Down Expand Up @@ -210,6 +232,36 @@ function Test-Parameters {
LogMessage "Parameters verified."
}

<<<<<<< HEAD
=======
# Force kill a process by process name
function KillProcessByName {
param(
[Parameter(Mandatory = $true)]
[string]$ProcessName
)

$processes = Get-Process | Where-Object { $_.ProcessName -eq $ProcessName }
$processCount = $processes | Measure-Object | Select-Object -ExpandProperty Count

if ($processCount -eq 0) {
LogMessage "No processes with the name '$ProcessName' are currently running."
}
else {
foreach ($process in $processes) {
try {
$processID = $process.Id
Stop-Process -Id $processID -Force
LogMessage "Killed process '$ProcessName' (ID $processID) successfully."
}
catch {
LogMessage "Failed to kill process '$ProcessName' (ID $processID): $($_.Exception.Message)"
}
}
}
}

>>>>>>> parent of 0c29984 (Update Datto RMM script to latest PoSh v2)
# check to see if the Huntress service exists (agent or updater)
function Confirm-ServiceExists ($service) {
if (Get-Service $service -ErrorAction SilentlyContinue) {
Expand Down Expand Up @@ -330,7 +382,11 @@ function Install-Huntress ($OrganizationKey) {
verifyInstaller($InstallerPath)

LogMessage "Executing installer..."
<<<<<<< HEAD

=======

>>>>>>> parent of 0c29984 (Update Datto RMM script to latest PoSh v2)
$process = Start-Process $InstallerPath "/ACCT_KEY=`"$AccountKey`" /ORG_KEY=`"$OrganizationKey`" /S" -PassThru

try {
Expand Down Expand Up @@ -375,7 +431,11 @@ function Test-Installation {
Start-Sleep -Milliseconds 250
}
if ( ! $didAgentRegister) {
<<<<<<< HEAD
$err = "WARNING: It does not appear the agent has succesfully registered. Check 3rd party AV exclusion lists to ensure Huntress is excluded."
=======
$err = "WARNING: It does not appear the agent has successfully registered. Check 3rd party AV exclusion lists to ensure Huntress is excluded."
>>>>>>> parent of 0c29984 (Update Datto RMM script to latest PoSh v2)
Write-Output $err -ForegroundColor white -BackgroundColor red
LogMessage ($err + $SupportMessage)
}
Expand Down Expand Up @@ -589,6 +649,14 @@ function uninstallHuntress {
Stop-Service "huntressupdater" -ErrorAction SilentlyContinue
Stop-Service "huntressagent" -ErrorAction SilentlyContinue

<<<<<<< HEAD
=======
# Force kill the executables so they're not hangin around
KillProcessByName "HuntressAgent.exe"
KillProcessByName "HuntressUpdater.exe"
KillProcessByName "HuntressRio.exe"

>>>>>>> parent of 0c29984 (Update Datto RMM script to latest PoSh v2)
# attempt to use the built in uninstaller, if not found use the uninstallers built into the Agent and Updater
if (Test-Path $agentPath) {
# run uninstaller.exe, if not found run the Agent's built in uninstaller and the Updater's built in uninstaller
Expand Down Expand Up @@ -810,9 +878,21 @@ function copyLogAndExit {
Start-Sleep 1
$agentPath = getAgentPath
$logLocation = Join-Path $agentPath "HuntressPoShInstaller.log"
<<<<<<< HEAD
if (!(Test-Path -path $agentPath)) {New-Item $agentPath -Type Directory}
Copy-Item -Path $DebugLog -Destination $logLocation -Force
Write-Output "$($DebugLog) copied to $agentPath"
=======

# If this is an unistall, we'll leave the log in the C:\temp dir otherwise,
# we'll copy the log to the huntress directory
if (!$uninstall){
if (!(Test-Path -path $agentPath)) {New-Item $agentPath -Type Directory}
Copy-Item -Path $DebugLog -Destination $logLocation -Force
Write-Output "$($DebugLog) copied to $agentPath"
}

>>>>>>> parent of 0c29984 (Update Datto RMM script to latest PoSh v2)
Write-Output "Script complete"
exit 0
}
Expand Down Expand Up @@ -919,4 +999,7 @@ try {
LogMessage $ErrorMessage
copyLogAndExit
}
<<<<<<< HEAD
>>>>>>> parent of d661565 (Update deployment ps1 for DattoRMM)
=======
>>>>>>> parent of 0c29984 (Update Datto RMM script to latest PoSh v2)

0 comments on commit bec5a79

Please sign in to comment.