titandude2k6 1 Posted February 18, 2014 Share Posted February 18, 2014 I've got thousands of agents I need to delete somehow, easier than deleting one by one. They are either agents that are on PCs and servers that have been decommissioned or customers who have left us. Is there a script to automate deletion of PCs marked as offline and haven't checked in in a while? Quote Link to post Share on other sites
bkuzma 0 Posted February 19, 2014 Share Posted February 19, 2014 Here's two scripts that accomplish this. 1. Cleanup Active Agents - Run this against your labtech server. It will call a second script for all computers that haven't pulsed in in the last 30 days. 2. !Delete Computer From Labtech - This script calls a stored procedure to remove the computer. Cleanup Inactive Agents.zip Quote Link to post Share on other sites
titandude2k6 1 Posted February 19, 2014 Author Share Posted February 19, 2014 ok great thank you! how do i run a script against the LT server? Quote Link to post Share on other sites
bkuzma 0 Posted February 19, 2014 Share Posted February 19, 2014 Technically, you could pick any machine to run the script on, but for sake of simplicity, all of our "Practice Management" scripts are run on the Labtech Server. If you are cloud-hosted, you won't have this option. Quote Link to post Share on other sites
titandude2k6 1 Posted February 20, 2014 Author Share Posted February 20, 2014 thanks yeah i forgot to install an agent on my LT servers. Quote Link to post Share on other sites
AndyA 0 Posted May 7, 2014 Share Posted May 7, 2014 This is just what I was looking for, worked a treat, thanks! Andy Quote Link to post Share on other sites
Sebastian 0 Posted August 6, 2014 Share Posted August 6, 2014 Worked like a charm! Thank you Quote Link to post Share on other sites
Darrell_Null 0 Posted August 21, 2014 Share Posted August 21, 2014 Quick question. The SQL query shows Quote Link to post Share on other sites
titandude2k6 1 Posted October 3, 2014 Author Share Posted October 3, 2014 JUst an FYI...I've found its been easier for me to go the dataview route. Run a dataview against all my agents. I can show tons of different fields and sort it how i want, then select all of the agents I want and then rlght click and delete. 1 Quote Link to post Share on other sites
ccraig 0 Posted November 24, 2014 Share Posted November 24, 2014 Quick question. The SQL query shows Seeing as how the SQL query does all the work, I would say that its 30 days. Quote Link to post Share on other sites
vkent39 2 Posted January 11, 2015 Share Posted January 11, 2015 I can't seem to run the !Delete script although it appears in the scripts view it is not available for any machines. Quote Link to post Share on other sites
chris.mathis 0 Posted January 14, 2015 Share Posted January 14, 2015 I can't seem to run the !Delete script although it appears in the scripts view it is not available for any machines. You cannot directly run that script or at least your not supposed to, it is run from the Cleanup Inactive Agents Script. Quote Link to post Share on other sites
vkent39 2 Posted January 14, 2015 Share Posted January 14, 2015 Makes sense as it worked great. Thank you Quote Link to post Share on other sites
paulms53 0 Posted August 4, 2015 Share Posted August 4, 2015 is there any way to email the results of the first script? Quote Link to post Share on other sites
colonel 0 Posted August 20, 2015 Share Posted August 20, 2015 Hi, I've imported both scripts but I can't see them. I'm using LabTech 10 on the cloud. Quote Link to post Share on other sites
DOTCOM 0 Posted October 16, 2015 Share Posted October 16, 2015 Hi Everyone, I am new to LabTech so please go easy on me. How do I translate the .xml files into a script? Is there an import function? Do I just copy and paste the info from the xml into the new script dialogue? DC Quote Link to post Share on other sites
josh.ishak 1 Posted October 19, 2015 Share Posted October 19, 2015 Hi Everyone, I am new to LabTech so please go easy on me. How do I translate the .xml files into a script? Is there an import function? Do I just copy and paste the info from the xml into the new script dialogue? DC The .XML files are the format that LT exports/imports scripts as. Just hit Tools > Import > LT XML Expansion and point it to the scripts that you want to import. If you don't want to chase around looking for it (post-import), I would say edit the XML and remove the values for the and at the beginning of the script before you import it. This will give the script a new ID when you add it, and place it in the root of the Scripts tree. Quote Link to post Share on other sites
DOTCOM 0 Posted November 12, 2015 Share Posted November 12, 2015 Omg. Thank you Josh. I wish to run the script every 30 days on machines that have not checked back within 90 days. Please let me know if I have this scripted correctly. select computers.`computerid` from computers where computers.`LastContact` < DATE_ADD(Now(), INTERVAL -90 DAY) Then I schedule this script to run against the LabTech server on a monthly cycle (say first day), would this be correct? Thanks for all your help! Quote Link to post Share on other sites
SteveTeece 0 Posted November 13, 2015 Share Posted November 13, 2015 Omg. Thank you Josh. I wish to run the script every 30 days on machines that have not checked back within 90 days. Please let me know if I have this scripted correctly. select computers.`computerid` from computers where computers.`LastContact` < DATE_ADD(Now(), INTERVAL -90 DAY) Then I schedule this script to run against the LabTech server on a monthly cycle (say first day), would this be correct? [attachment=0]Monthly Schedule.png[/attachment] Thanks for all your help! That's it. Should do exactly as you described above, running on the 1st of each month Quote Link to post Share on other sites
odirex 0 Posted December 5, 2015 Share Posted December 5, 2015 Thank you for this script! I've been deleting old PCs manually on our server for years. Quote Link to post Share on other sites
NetOps 1 Posted December 30, 2015 Share Posted December 30, 2015 According to Clean up Inactive Agents script, its removing all the agents that haven't checked in for the past 30 days. I don't see 90 days being configured any where. Is that correct ? The Delete computer script is calling a stored procedure but has a note that says automatically delete computers, computer was offline for 90 days. So, if an agent didn't check in for the past 30 days, it will removed. Can someone please confirm this? Thanks ! Quote Link to post Share on other sites
jamesvictorio 0 Posted July 24, 2017 Share Posted July 24, 2017 Do we have a script that also creates a report of what machines were removed? Quote Link to post Share on other sites
phmcgann 0 Posted August 1, 2017 Share Posted August 1, 2017 Do we have a script that also creates a report of what machines were removed? James, I use the following script: I have it set to run daily on my Automate server directly. It not only removes all agents which have not checked in within the last 90 days, but it also delivers an e-mailed report to me with all of the agents which were removed which ends up looking like this when it's delivered to me: The script attached should be totally sanitized, so it is safe to import without fear of it overwriting another script with the same ID or anything. I have a separate group which contains just my Automate server which I run this script on (as well as others similar to it that I only want to run on my Automate server). If you do something similar, you either need to update the advanced settings to include your username by adding the parameter, LTRUNBYUSER=YOURUSERNAME|, also as shown below. Or just modify the script on lines 19+24 to send the e-mail directly to whatever e-mail address you want instead of using the e-mail address associated with the username of the account which ran the script. If you don't do either, it will try and pull the e-mail address of the root user, which should be the default user that schedules scripts on groups when none other is specified, and so you won't actually receive the report in e-mail format. Agent Removal over 90 days.zip Quote Link to post Share on other sites
szkoda 5 Posted August 3, 2017 Share Posted August 3, 2017 Script works like a charm, I have also edited it to 30 days instead. Can I assign this script to the "LT - Agents No Checkin for More Than 30 Days*" monitor to run when the monitor fails rather than on a set schedule? Quote Link to post Share on other sites
Darrell_Null 0 Posted August 4, 2017 Share Posted August 4, 2017 szkoda, the biggest issue with assigning to the monitor that I can see off the top of my head would be let's say that you have 20 agents all hitting 30 days old on the same day distributed throughout the day, you script would fire off 20 times during the day. If that is not a huge issue for you then technically I think it would be okay. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.