View the JNUC Video http://www.jamfsoftware.com/resources/solving-real-needs-with-the-command-line/
Assigning a Computer to a User using Last Login
This will assign a computer record in the JSS to the user that last logged into the computer.
- Create a new Policy or edit existing Inventory Policy
- In the Files and Processes Payload add to Execute Command:
jamf recon -endUsername $(defaults read /Library/Preferences/com.apple.loginwindow lastUserName)
Smart Group from Dummy Receipt
Create a Smart Group based on the existence of a file on a computer.
1. During provisioning or imaging place a file on the computer with a package or script for example:
echo "Kiosk" > "/Library/Application Support/Company/computerType"
2. Create an Extension Attribute populated with a script:
#!/bin/bash
computerType="/Library/Application Support/Company/computerType"
[ -e "$computerType" ] && echo "<result>$(cat "$computerType")</result>" || echo "<result>None</result>"
3. Create a Smart Group with "Computer Type" as criteria.
Promoting or Demoting Users
Turn all users on a computer to standard accounts except a specific user.
- Create a script in the JSS:
#!/bin/bash # Define user to ignore in the array adminUserToSkip="$4" # Create User Array userList=$(dscl . list /Users UniqueID | awk '$2 > 500 {print $1}') # Go through array skipping our user to keep for user in ${userList[@]};do [ "$user" == "$adminUserToSkip" ] && continue; dseditgroup -o edit -d "$user" -t user admin done - Name Parameter 4 to "Account to Keep as Admin"
- Create a Policy that deploys the script with the account name in Parameter 4.
To make all users admins changetodseditgroup -o edit -d "$user" -t user admindseditgroup -o edit -a "$user" -t user admin
