Skip to main content
Solved

Automate User removal from Casper

  • May 10, 2015
  • 6 replies
  • 22 views

Forum|alt.badge.img+7

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/

Best answer by qsodji

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

6 replies

loceee
Forum|alt.badge.img+10
  • Contributor
  • May 11, 2015

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!


Forum|alt.badge.img+7
  • Author
  • Contributor
  • May 11, 2015

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
Forum|alt.badge.img+27
  • Esteemed Contributor
  • May 11, 2015

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


Forum|alt.badge.img+7
  • Author
  • Contributor
  • Answer
  • May 11, 2015

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


Forum|alt.badge.img+7
  • Author
  • Contributor
  • May 11, 2015

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.


Forum|alt.badge.img+7
  • Author
  • Contributor
  • May 16, 2015

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