Hi all
I'm working on automating back ups for users that have left the company, the policy/script will run whilst logged in as the local administrator as the user's account will more than likely be disabled at this point.
I'd like part of the script to get the username of the latest logged in Active Directory user so we know we're back up the correct home folder and creating a directory with the correct name on the network share.
What i have so far works to select just the domain account home folders and exclude any local accounts, but the part i can't get to work is how to select the folder that has the latest modified date, from what i can see on the Googlesphere head -1 should get the last modified folder but in my testing that's not working.
Can anyone suggets a different way to skin this cat or why the command is not picking up the last modified folder ?
#!/bin/sh
lastaduser=$( find /Users/ -mindepth 1 -maxdepth 1 -type d -group "OURDOMAINDomain Users" | head -1 | cut -f 4 -d'/' )
echo "$lastaduser"