From 423c28b31776b94a3181c4f57ebdcd4e9b7b06ee Mon Sep 17 00:00:00 2001 From: Zack T Date: Tue, 30 Oct 2018 12:43:37 -0700 Subject: [PATCH] v1.0 = Initial Version + Initial Version --- .../Extension Attributes/jamf_ea_LastUser.sh | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 Jamf Pro/Extension Attributes/jamf_ea_LastUser.sh diff --git a/Jamf Pro/Extension Attributes/jamf_ea_LastUser.sh b/Jamf Pro/Extension Attributes/jamf_ea_LastUser.sh new file mode 100644 index 0000000..ab8f3bd --- /dev/null +++ b/Jamf Pro/Extension Attributes/jamf_ea_LastUser.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +################################################################################################### +# Script Name: jamf_ea_LastUser.sh +# By: Zack Thompson / Created: 10/30/2018 +# Version: 1.0 / Updated: 10/30/2018 / By: ZT +# +# Description: A Jamf Extension Attribute that displays the last user to log in. +# +################################################################################################### + +lastUser=$(/usr/bin/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");') + +if [[ -z $lastUser ]]; then + echo "No logins" +else + echo "${lastUser}" +fi + +exit 0 \ No newline at end of file