-
Notifications
You must be signed in to change notification settings - Fork 0
/
Popup_to_Request_Logging_In_Apple_ID.sh
48 lines (35 loc) · 1.35 KB
/
Popup_to_Request_Logging_In_Apple_ID.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
#Matthew Prins 2022
#https://github.com/MatthewPrins/Jamf/
#Initiates a pop-up requesting a user login with the proper Apple ID on the computer
#Set as policy in Jamf
###########################
#Editable variables
#Domain the Apple ID user should have
correctDomain="@xxxxxx.com"
#Message for user not logged in
notLoggedIn="Please login to your proper Apple ID."
#Message for user logged in to the wrong account
wrongLoggedIn="Please logout of your personal Apple ID and login with your proper Apple ID."
#Title for popup window
title="Apple ID Warning"
#Heading for popup window
heading="Please Note"
###########################
# Get logged-in user
loggedInUser=$(stat -f%Su /dev/console)
# Get iCloud account for logged-in user
icloudaccount=$( defaults read /Users/$loggedInUser/Library/Preferences/MobileMeAccounts.plist Accounts | grep AccountID | cut -d '"' -f 2)
if [[ "$icloudaccount" != *"$correctDomain" ]]
then
if [[ "$icloudaccount" == "" ]]
then
message="$notLoggedIn"
else
message="$wrongLoggedIn"
fi
#popup message
"/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper" -windowType utility -title "$title" -heading "$heading" -description "$message" -button1 "OK"
#open Apple ID pane in System Preferences
open -b com.apple.systempreferences /System/Library/PreferencePanes/AppleIDPrefPane.prefPane
fi