Clear snapin history? Automatically?
Szeraax last edited by
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.
Szeraax last edited by
@cml Better mark this as solved. Loved it!
Szeraax last edited by Szeraax
@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.
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.
Wayne Workman last edited by
A cron job could also run the last line of SQL that @cml posted on a schedule.
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);