Posted on 05-09-2015 08:14 PM
Hi All,
While wondering about a way to automated the removal of departed users from casper I wrote a script that uses the REST API to accomplish that.
It relies on the python-jss module and finds all users without a computers assigned to them and removed them from the JSS. Also sends out an email with a list of users that were deleted.
Feedbacks are welcome as always.
Cheers
https://jumpt.wordpress.com/2015/05/09/automate-users-removal-from-casper-via-rest-api/
Solved! Go to Solution.
Posted on 05-10-2015 10:51 PM
@jhbush1973 That is up to you, I have tested both. You can have python-jss installed on the JSS master and have the script also live there. Setup a con job on the same server to call the script (once a week should be good enough).
I have also tested the script from a VM that had python-jss installed on it and it worked fine.
Should you choose to keep the script on your JSS master, I would recommend using 127.0.0.1:8443 instead.
I am very happy you find it useful.
Posted on 05-10-2015 07:16 PM
Great idea! I was just looking through my users in the JSS for VPP. It's totally full of cruft, old local junky local usernames from unmanaged Macs. Look forward to checking it out!
Posted on 05-10-2015 08:17 PM
Awesome, you can definitely use it for that purpose, might need to tweak it a bit. Then again if those users you need to remove don't have any assets (computer,mobile,VPP,etc..) it will work right off the bat.
Posted on 05-10-2015 10:42 PM
@qsodji forgive my ignorance but are you installing Shea's python-jss module on your JSS master and running your CRON job from there? Thank you for sharing this very useful script.
Posted on 05-10-2015 10:51 PM
@jhbush1973 That is up to you, I have tested both. You can have python-jss installed on the JSS master and have the script also live there. Setup a con job on the same server to call the script (once a week should be good enough).
I have also tested the script from a VM that had python-jss installed on it and it worked fine.
Should you choose to keep the script on your JSS master, I would recommend using 127.0.0.1:8443 instead.
I am very happy you find it useful.
Posted on 05-11-2015 03:36 PM
Quick update...
Added support for Slack. You can now either receive and email, output list of users to a slack group or both.
Slack integration also supports multiple channels/private groups.
Also there is now a setup script that will install all the needed modules.
Posted on 05-15-2015 07:52 PM
@jhbush1973 I wanted to add a quick update to your question. In my shop, I have the script in docker. The whole is controlled by Jenkins which handles building the entire container with the needed dependencies and run the script. Jenkins handles all the alerting and building.