Automate User removal from Casper

qsodji
Contributor

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/

1 ACCEPTED SOLUTION

qsodji
Contributor

@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.

View solution in original post

6 REPLIES 6

loceee
Contributor

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!

qsodji
Contributor

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.

jhbush
Valued Contributor II

@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.

qsodji
Contributor

@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.

qsodji
Contributor

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.

qsodji
Contributor

@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.