Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions Datto-RMM/scripts/InstallHuntress.dattormm.comstore.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -801,23 +801,21 @@ 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

# 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)"
Expand Down Expand Up @@ -870,7 +868,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-CimInstance -computername $env:computername -Class win32_operatingSystem).caption.Trim()
} catch {
LogMessage "WMI issues discovered (computer name query), attempting to fix the repository"
winmgmt -verifyrepository
Expand Down
Loading