From 4dda913886391e322f1988220b5f2ef74799400f Mon Sep 17 00:00:00 2001 From: "Alan Bishop [Huntress]" <109673875+Alan-Huntress@users.noreply.github.com> Date: Thu, 20 Nov 2025 13:21:03 -0500 Subject: [PATCH 1/4] Improved post-uninstall service removal --- Datto-RMM/scripts/InstallHuntress.dattormm.comstore.ps1 | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Datto-RMM/scripts/InstallHuntress.dattormm.comstore.ps1 b/Datto-RMM/scripts/InstallHuntress.dattormm.comstore.ps1 index 5749d4f..45a1886 100644 --- a/Datto-RMM/scripts/InstallHuntress.dattormm.comstore.ps1 +++ b/Datto-RMM/scripts/InstallHuntress.dattormm.comstore.ps1 @@ -14,7 +14,7 @@ # OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # -# Authors: Alan Bishop, Sharon Martin, John Ferrell, Dave Kleinatland, Cameron Granger +# Authors: Alan Bishop, Sharon Martin, John Ferrell, Dave Kleinatland, Evan Shewchuck # The Huntress installer needs an Account Key and an Organization Key (a user specified name or description) which is used to affiliate an Agent with a @@ -104,7 +104,7 @@ $estimatedSpaceNeeded = 200111222 ############################################################################## # These are used by the Huntress support team when troubleshooting. -$ScriptVersion = "Version 2, major revision 8, 2025 Nov 19" +$ScriptVersion = "Version 2, major revision 8, 2025 Nov 20" $ScriptType = "PowerShell (Datto)" # variables used throughout this script @@ -726,7 +726,7 @@ function uninstallHuntress { # if Huntress services still exist, then delete $services = @("HuntressRio", "HuntressAgent", "HuntressUpdater", "Huntmon") foreach ($service in $services) { - if ( $service ) { + if ( Get-Service -name $service -erroraction SilentlyContinue ) { LogMessage "Service $($service) detected post uninstall, attempting to remove" c:\Windows\System32\sc.exe STOP $service c:\Windows\System32\sc.exe DELETE $service @@ -870,7 +870,8 @@ function logInfo { LogMessage $(systeminfo) #LogMessage "Host name: '$env:computerName'" - try { $os = (get-WMiObject -computername $env:computername -Class win32_operatingSystem).caption.Trim() + try { + $os = (get-WMiObject -computername $env:computername -Class win32_operatingSystem).caption.Trim() } catch { LogMessage "WMI issues discovered (computer name query), attempting to fix the repository" winmgmt -verifyrepository From 6d3d272418eccf468975ec6e8001fa4a6951030b Mon Sep 17 00:00:00 2001 From: "Alan Bishop [Huntress]" <109673875+Alan-Huntress@users.noreply.github.com> Date: Thu, 20 Nov 2025 13:30:30 -0500 Subject: [PATCH 2/4] Update InstallHuntress.dattormm.comstore.ps1 --- Datto-RMM/scripts/InstallHuntress.dattormm.comstore.ps1 | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Datto-RMM/scripts/InstallHuntress.dattormm.comstore.ps1 b/Datto-RMM/scripts/InstallHuntress.dattormm.comstore.ps1 index 45a1886..459b5ba 100644 --- a/Datto-RMM/scripts/InstallHuntress.dattormm.comstore.ps1 +++ b/Datto-RMM/scripts/InstallHuntress.dattormm.comstore.ps1 @@ -801,8 +801,7 @@ function testNetworkConnectivity { foreach ($URL in $URLs) { $StatusCode = 0 - try - { + try { $Response = Invoke-WebRequest -Uri $URL -TimeoutSec 5 -ErrorAction Stop -ContentType "text/plain" -UseBasicParsing # This will only execute if the Invoke-WebRequest is successful. $StatusCode = $Response.StatusCode @@ -810,14 +809,13 @@ function testNetworkConnectivity { # Convert from bytes, if necessary if ($Response.Content.GetType() -eq [System.Byte[]]) { $StrContent = [System.Text.Encoding]::UTF8.GetString($Response.Content) - }else { + } else { $StrContent = $Response.Content.ToString().Trim() } # Remove all newlines from the content $StrContent = [string]::join("",($StrContent.Split("`n"))) - $ContentMatch = $StrContent -eq "96bca0cef10f45a8f7cf68c4485f23a4" } catch { LogMessage "Error: $($_.Exception.Message)" From 0638fb2ebe85820f0ed6703a226f1d7d70378ed4 Mon Sep 17 00:00:00 2001 From: "Alan Bishop [Huntress]" <109673875+Alan-Huntress@users.noreply.github.com> Date: Thu, 20 Nov 2025 13:31:15 -0500 Subject: [PATCH 3/4] remove trailing space --- Datto-RMM/scripts/InstallHuntress.dattormm.comstore.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Datto-RMM/scripts/InstallHuntress.dattormm.comstore.ps1 b/Datto-RMM/scripts/InstallHuntress.dattormm.comstore.ps1 index 459b5ba..fd2f08f 100644 --- a/Datto-RMM/scripts/InstallHuntress.dattormm.comstore.ps1 +++ b/Datto-RMM/scripts/InstallHuntress.dattormm.comstore.ps1 @@ -868,7 +868,7 @@ function logInfo { LogMessage $(systeminfo) #LogMessage "Host name: '$env:computerName'" - try { + try { $os = (get-WMiObject -computername $env:computername -Class win32_operatingSystem).caption.Trim() } catch { LogMessage "WMI issues discovered (computer name query), attempting to fix the repository" From f9f2fa0ba621c93d16dc16962ccd2d365c4ecdb7 Mon Sep 17 00:00:00 2001 From: "Alan Bishop [Huntress]" <109673875+Alan-Huntress@users.noreply.github.com> Date: Thu, 20 Nov 2025 14:36:40 -0500 Subject: [PATCH 4/4] Pivoting to Get-CimInstance on Evan's advice --- Datto-RMM/scripts/InstallHuntress.dattormm.comstore.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Datto-RMM/scripts/InstallHuntress.dattormm.comstore.ps1 b/Datto-RMM/scripts/InstallHuntress.dattormm.comstore.ps1 index fd2f08f..16c524b 100644 --- a/Datto-RMM/scripts/InstallHuntress.dattormm.comstore.ps1 +++ b/Datto-RMM/scripts/InstallHuntress.dattormm.comstore.ps1 @@ -14,7 +14,7 @@ # OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # -# Authors: Alan Bishop, Sharon Martin, John Ferrell, Dave Kleinatland, Evan Shewchuck +# Authors: Alan Bishop, Sharon Martin, John Ferrell, Dave Kleinatland, Evan Shewchuk # The Huntress installer needs an Account Key and an Organization Key (a user specified name or description) which is used to affiliate an Agent with a @@ -869,7 +869,7 @@ function logInfo { #LogMessage "Host name: '$env:computerName'" try { - $os = (get-WMiObject -computername $env:computername -Class win32_operatingSystem).caption.Trim() + $os = (Get-CimInstance -computername $env:computername -Class win32_operatingSystem).caption.Trim() } catch { LogMessage "WMI issues discovered (computer name query), attempting to fix the repository" winmgmt -verifyrepository