Skip to main content
Solved

Script to Mass Remove Home Folders in Users Directory

  • January 23, 2014
  • 34 replies
  • 61 views

Show first post

34 replies

Forum|alt.badge.img+21
  • Valued Contributor
  • August 9, 2015

Here you go:

Running command ls -lO /Users/cbcolli/.Trash/CONTENTS/AUDIO/0001PL00.MXF...
Result of command:
-rwxrwxrwx 1 cbcolli POINTPARKStudents uchg 28381312 Apr 1 13:03 /Users/cbcolli/.Trash/CONTENTS/AUDIO/0001PL00.MXF


Forum|alt.badge.img+10
  • Valued Contributor
  • August 9, 2015

Wow! that was fast. That appears to be the user immutable flag. The solution to this is going to be to run 'chflags -R nouchg' on the user's directory prior to running the shutil.rmtree operation. I'll edit the script above so that i incorporates the chflags command into it.


Forum|alt.badge.img+21
  • Valued Contributor
  • August 9, 2015

Awesome, thanks for taking the time to diagnose this and update the script. It's a huge help!


Forum|alt.badge.img+10
  • Valued Contributor
  • August 9, 2015

Glad to help! I've just finished making the changes. I made a few other alterations to clean up a few things. Let me know if you have any questions about what i did.


Forum|alt.badge.img+21
  • Valued Contributor
  • August 10, 2015

I just tried out the new script and it worked great on the systems that were previously experiencing problems. Thanks again!


Forum|alt.badge.img+19
  • Employee
  • August 10, 2015

Sorry @denmoff been bogged down in deployment! Can you send on a link to the updated script and I'll run it through tomorrow.
Thanks for the support!


Forum|alt.badge.img+10
  • Valued Contributor
  • August 11, 2015

@Zvordauk I've made the changes in my original script up above.


Forum|alt.badge.img+19
  • Employee
  • August 11, 2015

D'oh! That's the problem with skimming stuff after an 18 hour shift :(

I'm probably doing something very stupid but I'm getting the following error:

Script result: File "/Library/Application Support/JAMF/tmp/RemoveExtraUsers.py", line 41
except Exception, e:
^
SyntaxError: invalid syntax


Forum|alt.badge.img+10
  • Valued Contributor
  • August 11, 2015

@Zvordauk Probably because everything in the "try" statement is commented out. I've changed the script again so that has the print statement uncommented after the try statement. But don't forget that i've commented out the shutil.rmtree statement. You'll need to uncomment that line before it will actually do anything irrevocable.