Jump to content
pkburgess

Auto Remove Agents disconnected for > X days

Recommended Posts

Hi All,

First post so apologies if I'm in the wrong location on the forum. 

We are about 6 months into the roll out and already its becoming clear that disconnected agents where the devices has been retired or replaced need to be dealt with cleverly so stop a bulk building up. 

We have spoken to a number of clients and they are all of the opinion anything disconnected for more that 60 days can just be deleted. 

  • A:) What are your thoughts on this, how are you handling diconnected agents
  • B:) Is there a way to make Automate automate this process. ie Agent last connect >60 days = Retire asset
  • C:) If a retired asset comes back online after its been retired, how does Automate handle this. Does it move it back to live, does it warn you or does it continue to ignore it.

Thank you in advance for any thoughts or assistance. 

Regards

Patrick 

Share this post


Link to post
Share on other sites

I have a couple of old scripts that run once a week to remove any machines that have been inactive in more than 60 days.  One script to identify the machines to remove, which calls a second script that actually performs the removal.  I don't recall where I first came across them, but they've been working well enough for me.

The main part the first script runs the following command:
FOR each row in select computers.`computerid` from computers where computers.`LastContact` < DATE_ADD(Now(), INTERVAL -60 DAY) run script !Legacy Scripts\!Delete Computer from LabTech

And that is calling the second script that runs the actual delete command:
SQL EXECUTE: call sp_DeleteComputer(%sqlcomputerid%,'Automatically removed by Cleanup Inactive Agents. Computer was offline for more than 60 days')
 

In my experience, a retired machine that finally checks back in shows up without issue (aside from likely needing some updates).

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Basically as sjacobs said. Although the issue sometimes is that the pc gets retired and given away to an employee and some weeks/months later the employee switches the machine back on and it pops back up on your system. You have no real way of telling if that is now a machine still under the company maintenance agreement or a device that is retired. The only way to find that out is to confirm with the company again.

The best way is to try and get the client to tell you the agent is going to be retired so that you can get a chance to run an off-boarding script. We have one that does several things to off-board the machine.

1. Remove AV
2. Remove the packages folder (%ltsvcdir%packages - left behind when you uninstall the agent)
3. Remove any other folders you might create as part of your maintenance
4. Remove Prob Flag if this was a Probe machine (Update computers SET flags = flags & ~ 128 WHERE computerid=@computerid@)
5. Remove ScreenConnect
6. Run the standard LT Offboarding Script ( Maintenance\Agent\Offboarding)

The other thing we do is we have an extra data field on the computer that is a checkbox and it's name is, Offboard Computer. We then have a monitor, pretty much the same as the New Computer Detected monitor, that fires when this machine next comes online and that then runs the off-boarding script.

  • Thanks 1

Share this post


Link to post
Share on other sites

Hi Guys,

Thanks for the replies. This is very useful, I will have a play with some scripts and see if I can make them work. 

I will report back.

Regards 

Patrick 

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...