forked from pbowden-msft/ExtensionAttributes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOffice_DeviceID.xml
39 lines (32 loc) · 1.11 KB
/
Office_DeviceID.xml
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
<?xml version="1.0" encoding="UTF-8"?><extensionAttribute>
<displayName>Office DeviceID</displayName>
<description/>
<dataType>string</dataType>
<scriptContentsMac>#!/bin/sh
# Functions
function GetDeviceID {
# creates a list of local usernames with UIDs above 500 (not hidden)
userList=$( /usr/bin/dscl /Local/Default -list /Users uid | /usr/bin/awk '$2 >= 501 { print $1 }' )
while IFS= read aUser
do
# get the user's home folder path
HOMEPATH=$( eval /bin/echo ~$aUser )
# grab the device id from the Office365ServiceV2 log
local RESULT=$(/usr/bin/grep -m1 'iaaaa' $HOMEPATH/Library/Containers/com.microsoft.Office365ServiceV2/Data/Library/Caches/Microsoft/uls/com.microsoft.Office365ServiceV2/logs/*.log | cut -f8)
# checks to see if we got a hit
if [ "$RESULT" != "" ]; then
ID="$RESULT"
fi
done <<< "$userList"
/bin/echo "$ID"
}
## Main
DEVICEID=$(GetDeviceID)
if [ "$DEVICEID" != "" ]; then
/bin/echo "<result>$DEVICEID</result>"
else
/bin/echo "<result>Not detected</result>"
fi
exit 0</scriptContentsMac>
<scriptContentsWindows/>
</extensionAttribute>