Jump to content
doughardy

Remove another MSP LT Agent

Recommended Posts

Hope someone can shed some light.

I'm taking on board a few clients from another MSP that uses labtech. The other MSP isn't doing any offboarding or removing the labtech agent.

So i've created a script that I run from on machine after installing the agent manually and turn on the network probe.

The command just hangs on the script and times out. I can login to the machine running the probe and run the same command and it works everytime. Would love to get the script running as there are quite a few machines coming on that I don't really want to do manually. 

the main line of the script that fails is %ltsvcdir%\psexec.exe -h \\@pcName@ c:\windows\temp\Agent_Uninstall.exe

The agent_uninstall.exe is copied in a previous line on script ok. The process starts but nothing else happens. I've tried running with system option (-s) the script line runs as admin so it has access to the machine. 

Any help or other methods appreciated.

Doug

Share this post


Link to post
Share on other sites

Just attempting to install the agent on top of an existing one won't work.

But to Quote SlackBot: 

slackbot Custom Response [06:26] 
"%windir%\system32\WindowsPowerShell\v1.0\powershell.exe" "(new-object Net.WebClient).DownloadString('http://bit.ly/LTPoSh') | iex; Reinstall-LTService "

REM To rip and replace to a new server, add this: -Server https://yourserver.com -LocationID XXX
REM Full Docs at http://labtechconsulting.com/labtech-agent-powershell-module/

That module will handle the heavy lifting of cleaning the old agent off, then downloading and running the installer. You will still need to use a tool like psexec to push that command out, or a computer startup script pushed via GPO that tests for the agent and runs that command if the agent isn't installed. (You don't want to reinstall after every reboot..) 

Share this post


Link to post
Share on other sites

This is the agent_uninstall.exe not the install :)

The command works fine except when run manually on the network probe machine running in cmd. when you call the same command from a script via the probe machine the psexec service starts on the remote machine but the agent_uninstall never completes.

i

 

Share this post


Link to post
Share on other sites
2 hours ago, doughardy said:

This is the agent_uninstall.exe not the install :)

Sorry, I thought you said you were replacing another installation.. The LTPosh module has cmdlets/functions you could use such as Remove-LTService and Install-LTService, but I was specifically mentioning the ReInstall-LTService function which will REMOVE AND INSTALL in just one step.

Share this post


Link to post
Share on other sites

This is a timely thread for me to find. The MSP I work for just took on a client and their previous MSP used ConnectWise and did not offboard the machines. I have manually removed the old agent from the server that will be the network probe and this module looks perfect for moving the remaining computers to our server. I hope to get this taken care of this week, as we were just notified that our cloud server will be upgraded to v12 early next week. Has anyone tested this module with v12 to see if there are any issues?

Share this post


Link to post
Share on other sites

The powershell commands are all executed through agent side processing. Nothing is loaded into the server, there is no specific dependency on the server beyond being able to reach the new server you are trying to join to. (Therefore, it is compatible with any server.) You can download the .psm1 and permanently install it on each machine, or the more popular way is to use the powershell 1-line command shown to download and load the module on demand, allowing you to use the functions on any machine with Internet Access and PowerShell 2.0 or above.

Share this post


Link to post
Share on other sites

This is so great!  We have a huge client we are taking over one location at a time, so I needed a way to do this by subnet.  Came up with this little .bat:

for a = 1 to 254
\\domain.local\NETLOGON\PsExec.exe \\10.148.160.a -n 8 "%windir%\system32\WindowsPowerShell\v1.0\powershell.exe" "(new-object Net.WebClient).DownloadString('http://bit.ly/LTPoSh') | iex; Reinstall-LTService -server https://LABTECHSERVER.com -LocationID 320"
next a

@DarrenWhite99:  Do you know if the ReInstall-LTService command will continue to install it if it's not already there, or will it bomb out if there's nothing to uninstall?  The old MSP did remove some of their agents, but not others...

UPDATE: Confirmed it will install if not there!

Edited by timbo83251
new info

Share this post


Link to post
Share on other sites

I used a bit from many parts of this forum, and a little of my own batch file knowledge to create this. This BATCH script will create a loop from x to x (1-254 for example) and apply the variable to the end of an ip address to cycle through each IP on your network to rip and replace Labtech.

for /L %%a in (1,1,254) do c:\windows\ltsvc\PsExec.exe \\192.168.1.%%a -n 8 "%windir%\system32\WindowsPowerShell\v1.0\powershell.exe" "(new-object Net.WebClient).DownloadString('http://bit.ly/LTPoSh') | iex; Reinstall-LTService -server https://fqdnofLabtech.com -LocationID xxx"

Definition: for /L %%a in (1,1,254) = create a loop from 1-254 and store in value %%a (To be run from a batch file) 5-250 would look like (5,1,250)

Definition: 192.168.1.%%A = 192.168.1.1-254 (You can use any internal network IP's you wish)

 

RipAndReplaceLabtech - Sanitized.bat

Share this post


Link to post
Share on other sites

Can't seem to get the script to actually uninstall. RUnning it on just 1-2 machines at a time. It starts the uninstall, stops the labtech services, and then just hangs. Any ideas?

I am using 

PsExec.exe \\192.168.3.202 -n 8 "%windir%\system32\WindowsPowerShell\v1.0\powershell.exe" "(new-object
Net.WebClient).DownloadString('http://bit.ly/LTPoSh') | iex; Uninstall-LTService -server https://fqdn

Share this post


Link to post
Share on other sites

I have had trouble before running through psexec.. Try adding "  <NUL" to the end (without quotes).. You might need ^<NUL since you want that to be passed to the remote machine.

Share this post


Link to post
Share on other sites

I updated the Rip & Replace PowerShell script yesterday.

It will check:
• If an agent is not already installed, it will download the agent and install silently.
• If an agent is already installed, it will compare the existing server it's checking into, if it's your automate server, it will comment that it's already installed. If it's another MSP, it will download the uninstaller, run it, then download and install your agent to the same computer.

At the end, it will give you confirmation that it's checking in along with the ComputerID in Automate.

Edited by Braingears
forgot link

Share this post


Link to post
Share on other sites
On 1/18/2019 at 3:36 PM, Rafe Spaulding said:

I used a bit from many parts of this forum, and a little of my own batch file knowledge to create this. This BATCH script will create a loop from x to x (1-254 for example) and apply the variable to the end of an ip address to cycle through each IP on your network to rip and replace Labtech.

for /L %%a in (1,1,254) do c:\windows\ltsvc\PsExec.exe \\192.168.1.%%a -n 8 "%windir%\system32\WindowsPowerShell\v1.0\powershell.exe" "(new-object Net.WebClient).DownloadString('http://bit.ly/LTPoSh') | iex; Reinstall-LTService -server https://fqdnofLabtech.com -LocationID xxx"

Definition: for /L %%a in (1,1,254) = create a loop from 1-254 and store in value %%a (To be run from a batch file) 5-250 would look like (5,1,250)

Definition: 192.168.1.%%A = 192.168.1.1-254 (You can use any internal network IP's you wish)

 

RipAndReplaceLabtech - Sanitized.bat

This worked flawlessly.

  • Like 1

Share this post


Link to post
Share on other sites

I'll share what I have for powershell -- not working 100%  for the auto downloading of psexec to sysvol and stuff, but I tweak as needed.  You can prob see where I as going.  I'm sure someone can make it way better...

Write-Host "This script will use PSEXEC to run a powershell command on every remote PC on the a specific network to Replace and/or Install our Labtech Agent"
Write-Host "It will attempt to download PSEXEC.exe to the NETLOGON folder of the domain.  If this script fails, you may need to place it there manually."
Write-Host "You should be running this script from a domain controller AS ADMINISTRATOR"
Write-Host "Networks will be broken down into /24"

$SUBNET = Read-Host -Prompt 'Input the Network ID (e.g. 192.168.1.0)'
$SUBNET = $SUBNET.Substring(0,$SUBNET.Length-2)
$LocationID = Read-Host -Prompt 'Input the Labtech Location ID'
$Domain = $env:userdnsdomain
$PSEXECPATH = \\$Domain\NETLOGON\psexec.exe

#If (-Not(Test-Path -Path "C:\Windows\SYSVOL\domain\scripts\psexec.exe" -PathType leaf))
#{
#Invoke-WebRequest -Uri "https://ltserverfqdn.com/Labtech/Transfer/Tools/psexec.exe" -OutFile "C:\Windows\SYSVOL\domain\scripts\psexec.exe"
#}





Write-Host "Labtech will now be pushed out to '$SUBNET.0' and will go into Location '$LocationID'.  The location of PSEXEC is '$PSEXECPATH'"

$x=1
DO
{
$IP = "$SUBNET.$x"
Write-Host "$IP"

$ARGUMENTLIST = "-n 9 \\$IP C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe (new-object Net.WebClient).DownloadString('http://bit.ly/LTPoSh') | iex; Reinstall-LTService -server https://ltserverfqdn.com -LocationID $locationID"
Start-Process -filepath "$PSEXECPATH" -ArgumentList $ARGUMENTLIST

$x++
"Now `$x is $x"
} While ($x -le 254)

 

 

Share this post


Link to post
Share on other sites

We inherited a server farm from another vendor, and rebooting servers is not an option.  Can I use a script to uninstall the other vendor’s agent and install ours?

Thanks in advance!

Share this post


Link to post
Share on other sites
On 2/21/2019 at 11:47 PM, ZenTekDS said:

This worked flawlessly.

Did you have to add a password into the command? It does not seem to be working for me. 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...