Clear snapin history? Automatically?
-
I’ve decided to use Snapins as a sort of declarative state configuration (similar to DSC). As a result, my group of computers is scheduled to run all snapins every hour and is starting to make the snapin history page a bit largish. Is the best way to clear that via the database? Or have I missed something that can be done to clear it? Especially automatically would be cool. I’m assuming that I’ll need to make myself a script for cron to run though.
If curious, my configuration does stuff like pulling the Primary User from FOG and making sure that that is the ONLY admin besides the 2 local admin accounts on each computer (adding/removing as needed). Also pulls bitlocker recovery information from the machine if its not already stored in FOG (or will enable bitlocker automatically if not presently enabled when I solve that debacle). You may be thinking, WTF??? And I agree with you. This deployment is interesting and they don’t have domain admin control. Not even GPO control. The office is part of a MUCH larger org, and fog has turned out to be best administrator solution.
-
The only way I could find to clear it was through the database.
You could use the event scheduler to automatically clear the table.
Here’s what I came up with to remove completed tasks older than a month.
USE fog; CREATE EVENT clear_snapinTasks ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 MONTH DO DELETE FROM fog.snapinTasks WHERE stCompleteDate < DATE_SUB(NOW(), INTERVAL 1 MONTH);
-
A cron job could also run the last line of SQL that @cml posted on a schedule.
-
I think this could be handled with either method, though I think the DB procedure method is probably the least interfering. It wouldn’t rely on another service from Linux to be enabled and running at least.
-
@tom-elliott Thanks for the thoughts. And especially thank you for cml for the code, and Wayne for ALWAYS being amazing on the forums.
I’m just happy that I solved my other problem on my own (the post about running 64bit powershell snapins so I can use modules and such). Gettin better all the time. Actually, Tom, it may be worth making a 64bit powershell snapin template. Guess that may have to be my own PR to put in.
-
@cml Better mark this as solved. Loved it!