From bec5a79d470a868ce68410dede4d7a4969e9193a Mon Sep 17 00:00:00 2001 From: cameron-huntress Date: Fri, 1 Dec 2023 14:32:24 -0600 Subject: [PATCH] revert --- .../InstallHuntress.dattormm.comstore.ps1 | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/Datto-RMM/scripts/InstallHuntress.dattormm.comstore.ps1 b/Datto-RMM/scripts/InstallHuntress.dattormm.comstore.ps1 index dcb4564..7029440 100644 --- a/Datto-RMM/scripts/InstallHuntress.dattormm.comstore.ps1 +++ b/Datto-RMM/scripts/InstallHuntress.dattormm.comstore.ps1 @@ -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. # @@ -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 @@ -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 @@ -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) { @@ -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) { @@ -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 { @@ -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) } @@ -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 @@ -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 } @@ -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)