Skip to content

Instantly share code, notes, and snippets.

@smashism
Created December 2, 2016 22:40
Show Gist options
  • Save smashism/75ec3984f5cf549e32b450166c8946e5 to your computer and use it in GitHub Desktop.
Save smashism/75ec3984f5cf549e32b450166c8946e5 to your computer and use it in GitHub Desktop.
#!/bin/sh
# gets user and location data to populate computer record
# can run on policy at any time
# by emily
# last updated 2016-12-02
# Get the logged in users username
loggedInUser=$(python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + "\n");')
echo "Running recon for $loggedInUser `date`..."
# Run recon, submitting the user's username which can then perform an LDAP lookup
sudo jamf recon -endUsername $loggedInUser
echo "Finished running recon for $loggedInUser `date`..."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment