logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
LLCoolWas  
#1 Posted : Wednesday, November 22, 2017 10:08:45 PM(UTC)
LLCoolWas


Rank: Newbie

Joined: 12/21/2015(UTC)
Posts: 1
United States
Location: Tampa, Fl

Thanks: 2 times
Was thanked: 1 time(s) in 1 post(s)
Here is an easy way to silently uninstall and reinstall the ConnectWise Automate Agent through a Control Command.
All you need to do is replace the server FQDN inside the quotes on line 6, and the server password on line 8.
You can push it to many devices at once if you need to, but keep in mind your server's bandwith.
The script takes about 3 minutes to run on a single agent and ends with an output of the LTSVC Folder Contents and LTErrors.txt file in the Command History pane.
I suggest storing this in the "Command Toolbox" Extension for quick access.

AS ALWAYS: USE AT YOUR OWN RISK. I AM NOT RESPONSIBLE FOR ANYTHING.
Code:

#----Downloads Automate Uninstaller From your FQDN, Install or Download then Install Agent----
#!ps
#timeout=9000000
#maxlength=9000000
#ENTER YOUR FQDN INSIDE THE QUOTES ON THE LINE BELOW i.e.: 'http://automate.myfqdn.com'
$FQDN='http://automate.myfqdn.com'
#ENTER YOUR SERVER PASSWORD INSIDE THE QUOTES ON THE LINE BELOW (Located in the CONFIG table in the Automate database)
$SERVERPASS='syspass'
#--------------------------------------------------------
#--------------------------------------------------------
#--------------------------------------------------------
#--------------------------------------------------------
Write-Output "Your FQDN is set to: $($FQDN)"
Write-Output "Your System Password is set to: $($SERVERPASS)"
if (Test-Path c:\windows\ltsvc){
sc.exe config "LTService" start= disabled
sc.exe config "LTSvcMon" start= disabled
taskkill /im ltsvcmon.exe /f
taskkill /im lttray.exe /f
taskkill /im ltsvc.exe /f
$source = "$($FQDN)/labtech/service/LabUninstall.exe"
$Filename = [System.IO.Path]::GetFileName($source)
$dest = "C:\$Filename"
$wc = New-Object System.Net.WebClient
if (!(test-path $dest))
{if ((Test-Path $dest -OlderThan (Get-Date).AddHours(-24))){
Write-Output '-----------------------------------------'
Write-Output '------File is older than 24 hours old----'
Write-Output '------Deleting Old Uninstaller-----------'
Write-Output '-----------------------------------------'
remove-item C:\LabUninstall.exe}
Write-Output '-----------------------------------------'
write-Output '------Downloading Uninstaller Now--------'
Write-Output '-----------------------------------------'
Write-Output '-----------------------------------------'
$wc.DownloadFile($source, $dest)}
Else
{Write-Output '-----------------------------------------'
Write-Output '----Uninstaller Already Resides on C:\----'
Write-Output '---Using c:\Labuninstall.exe-------------'
Write-Output '---If you have issues with the uninstall-'
Write-Output '---Delete the uninstaller and run again--'}
Write-Output '-----------------------------------------'
Write-Output '---------------Uninstalling--------------'
C:\LabUninstall.exe /quiet /norestart
Write-Output '-----------------------------------------'
Write-Output '----Uninstall Started Waiting 90 Secs----'
Write-Output '-----------------------------------------'
Start-Sleep 90}
Else
{Write-Output '-----------------------------------------'
Write-Output '------LTSVC FOLDER DOES NOT EXIST--------'
Write-Output '-------SKIPPING UNINSTALL PROCESS---------'}
Write-Output '-----------------------------------------'
Write-Output '----------Download Agent Sequence---------'
Write-Output '-----------------------------------------'
$source2 = "$($FQDN)/labtech/service/LabTechRemoteAgent.msi"
$Filename = [System.IO.Path]::GetFileName($source2)
$dest2 = "C:\$Filename"
$wc = New-Object System.Net.WebClient
$file2 = 'C:\LabTechRemoteAgent.msi'
if (!(test-path $file2))
{if ((Test-Path $file2 -OlderThan (Get-Date).AddHours(-24))){
Write-Output '-----------------------------------------'
Write-Output '------File is older than 24 hours old----'
Write-Output '------Deleting Old Installer-----------'
Write-Output '-----------------------------------------'
remove-item C:\LabTechRemoteAgent.msi}
Write-Output '-----------------------------------------'
write-Output '--------Downloading Installer Now--------'
Write-Output '-----------------------------------------'
$wc.DownloadFile($source2, $dest2)}
Else
{Write-Output '----Installer Already Resides on C:\-----'
Write-Output '---Using c:\LabtechRemoteAgent.msi-------'
Write-Output '---If you have issues with the install---'
Write-Output '---Delete the installer and run again----'}
Write-Output '-----------------------------------------'
Write-Output '----------------Installing---------------'
Write-Output '-----------------------------------------'
msiexec.exe /i C:\LabTechRemoteAgent.msi /quiet /norestart SERVERADDRESS=$($FQDN) SERVERPASS=$($SERVERPASS)
Start-Sleep -s 60
Write-Output '-----------------------------------------'
Write-Output '------Verifying Services are Started-----'
Write-Output '-----------------------------------------'
sc.exe start ltsvcmon
sc.exe start ltservice
Write-Output '-----------------------------------------'
Write-Output '-------Contents of LTSVC Folder:---------'
Write-Output '-----------------------------------------'
ls c:\Windows\LTSVC
Write-Output '-----------------------------------------'
Write-Output '------Contents of LTErrors.txt File:-----'
Write-Output '-----------------------------------------'
type c:\windows\ltsvc\lterrors.txt
thanks 1 user thanked LLCoolWas for this useful post.
Will H on 12/6/2017(UTC)
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.