Jump to content
TPerry

Automatically remove machines offline for X days

Recommended Posts

Posted (edited)

Hi All,

New to Automate scripting so bear with me:
I am trying to create a script that will automatically remove agents that have been offline for more than X number of days. I found this on here but cant for the life of me get it to work.

 

I have modified the "LT - Agents No Checkin for More Than 30 Days*" Monitor and i get computers listed so that works fine. I created a script with the instructions from the above link:
 

 

Script to delete a computer:

  1. Create a new script
  2. Set IF section to 'True'
  3. Add SQL Execute function to the THEN section
    For the SQL Statment of the SQL Execute function, use the following:
    call sp_DeleteComputer(%sqlcomputerid%,'Automatically removed by Cleanup Inactive Agents. Computer was offline for more than 30 days')

     

  4. Save

But nothing happens

 

What am i doing wrong? Any help greatly received 🙂

Edited by TPerry

Share this post


Link to post
Share on other sites

I don't have any real insight into the monitor or why it is not working for you. I believe the %sqlcomputerid% is what may be holding you back. The computerid in that instance indicates it is being set from a SQL Dataset function. Do you have one of those?

Another avenue you could go is a script that runs on a weekly basis to run this check. I found this script awhile ago and have modified it a bit to suite our needs. Basically I have a script that runs every Friday against our Automate server that calls a number of maintenance scripts that we need to run. Running this against the Automate server will guarantee that it will run and wont be stopped by an offline machine and it makes it easy to reference for maintenance tasks.

The attached script is a scrubbed version of the one we use. The nice thing about it is you will get a nice report emailed of all machines that get dropped so you can find and log anything that may have gotten dropped that should not have.

Agent Removal over 60 days.xml

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×