Skip to content

Commit 1f7132f

Browse files
committed
Update to ReportOfficeLicense.sh
Script now reports 2016 and 2019 generation licenses. Changed name of script to remove "2016" designation.
1 parent d7ff93d commit 1f7132f

File tree

2 files changed

+118
-104
lines changed

2 files changed

+118
-104
lines changed

ReportOffice2016License.sh

Lines changed: 0 additions & 104 deletions
This file was deleted.

ReportOfficeLicense.sh

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
#!/bin/sh
2+
3+
<<ABOUT_THIS_SCRIPT
4+
-----------------------------------------------------------------------
5+
Written by: William Smith
6+
Professional Services Engineer
7+
Jamf
8+
bill@talkingmoose.net
9+
https://github.com/talkingmoose/Jamf-Scripts
10+
11+
Adapted from a script by: Paul Bowden
12+
Software Engineer
13+
Microsoft Corporation
14+
pbowden@microsoft.com
15+
https://github.com/pbowden-msft/Unlicense
16+
17+
Originally posted: January 7, 2017
18+
Last updated: September 22, 2018
19+
20+
Purpose: Use this script as part of an extension attribute in Jamf
21+
to report the type of Microsoft Office licensing in use.
22+
23+
Except where otherwise noted, this work is licensed under
24+
http://creativecommons.org/licenses/by/4.0/
25+
26+
"Communication happens when I know that you know what I know."
27+
28+
INSTRUCTIONS
29+
30+
1) Log in to the Jamf Pro server.
31+
2) In Jamf Pro navigate to Settings > Computer Management > Extension Attributes.
32+
3) Click the " + " button to create a new extension attribute with these settings:
33+
Display Name: Microsoft Office for Mac License
34+
Description: Reports Microsoft Office for Mac licenses in use.
35+
Data Type: String
36+
Inventory Display: Extension Attributes
37+
Input Type: Script
38+
Script: < Copy and paste this entire script >
39+
4) Save the extension attribute.
40+
5) Use Recon.app or "sudo jamf recon" to inventory a Mac with Office 2016 or 2019.
41+
6) View the results under the Extension Attributes payload
42+
of the computer's record or include the extension attribute
43+
when adding criteria to an Advanced Computer Search or Smart Group.
44+
45+
-----------------------------------------------------------------------
46+
ABOUT_THIS_SCRIPT
47+
48+
49+
# Functions
50+
function DetectPerpetualLicense {
51+
perpetualLicense="/Library/Preferences/com.microsoft.office.licensingV2.plist"
52+
53+
# checks to see if a perpetual license file is present and what kind
54+
if [[ $( /bin/cat "$perpetualLicense" | grep "A7vRjN2l/dCJHZOm8LKan11/zCYPCRpyChB6lOrgfi" ) ]]; then
55+
echo "Office 2019 Volume"
56+
elif [[ $( /bin/cat "$perpetualLicense" | grep "Bozo+MzVxzFzbIo+hhzTl4JKv18WeUuUhLXtH0z36s" ) ]]; then
57+
echo "Office 2019 Preview Volume"
58+
elif [[ $( /bin/cat "$perpetualLicense" | grep "A7vRjN2l/dCJHZOm8LKan1Jax2s2f21lEF8Pe11Y+V" ) ]]; then
59+
echo "Office 2016 Volume"
60+
elif [[ $( /bin/cat "$perpetualLicense" | grep "DrL/l9tx4T9MsjKloHI5eX" ) ]]; then
61+
echo "Office 2016 Home and Business"
62+
elif [[ $( /bin/cat "$perpetualLicense" | grep "C8l2E2OeU13/p1FPI6EJAn" ) ]]; then
63+
echo "Office 2016 Home and Student"
64+
elif [[ $( /bin/cat "$perpetualLicense" | grep "Bozo+MzVxzFzbIo+hhzTl4m" ) ]]; then
65+
echo "Office 2019 Home and Business"
66+
elif [[ $( /bin/cat "$perpetualLicense" | grep "Bozo+MzVxzFzbIo+hhzTl4j" ) ]]; then
67+
echo "Office 2019 Home and Student"
68+
else
69+
echo "No"
70+
fi
71+
}
72+
73+
function DetectO365License {
74+
# creates a list of local usernames with UIDs above 500 (not hidden)
75+
userList=$( /usr/bin/dscl /Local/Default -list /Users uid | /usr/bin/awk '$2 >= 501 { print $1 }' )
76+
77+
while IFS= read aUser
78+
do
79+
# get the user's home folder path
80+
homePath=$( eval echo ~$aUser )
81+
82+
# list of potential Office 365 activation files
83+
O365SUBMAIN="$homePath/Library/Group Containers/UBF8T346G9.Office/com.microsoft.Office365.plist"
84+
O365SUBBAK1="$homePath/Library/Group Containers/UBF8T346G9.Office/com.microsoft.e0E2OUQxNUY1LTAxOUQtNDQwNS04QkJELTAxQTI5M0JBOTk4O.plist"
85+
O365SUBBAK2="$homePath/Library/Group Containers/UBF8T346G9.Office/e0E2OUQxNUY1LTAxOUQtNDQwNS04QkJELTAxQTI5M0JBOTk4O" # hidden file
86+
O365SUBMAINB="$homePath/Library/Group Containers/UBF8T346G9.Office/com.microsoft.Office365V2.plist"
87+
O365SUBBAK1B="$homePath/Library/Group Containers/UBF8T346G9.Office/com.microsoft.O4kTOBJ0M5ITQxATLEJkQ40SNwQDNtQUOxATL1YUNxQUO2E0e.plist"
88+
O365SUBBAK2B="$homePath/Library/Group Containers/UBF8T346G9.Office/O4kTOBJ0M5ITQxATLEJkQ40SNwQDNtQUOxATL1YUNxQUO2E0e"
89+
90+
# checks to see if an O365 subscription license file is present for each user
91+
if [[ -f "$O365SUBMAIN" || -f "$O365SUBBAK1" || -f "$O365SUBBAK2" || -f "$O365SUBMAINB" || -f "$O365SUBBAK1B" || -f "$O365SUBBAK2B" ]]; then
92+
activations=$((activations+1))
93+
fi
94+
done <<< "$userList"
95+
96+
# returns the number of activations to O365Activations
97+
echo $activations
98+
}
99+
100+
## Main
101+
102+
PLPresent=$(DetectPerpetualLicense)
103+
O365Activations=$(DetectO365License)
104+
105+
if [ "$PLPresent" != "No" ] && [ "$O365Activations" ]; then
106+
echo "<result>$PLPresent and Office 365 licenses detected. Only the $PLPresent license will be used.</result>"
107+
108+
elif [ "$PLPresent" != "No" ]; then
109+
echo "<result>$PLPresent license</result>"
110+
111+
elif [ "$O365Activations" ]; then
112+
echo "<result>Office 365 activations: $O365Activations</result>"
113+
114+
elif [ "$PLPresent" == "No" ] && [ ! "$O365Activations" ]; then
115+
echo "<result>No licenses</result>"
116+
fi
117+
118+
exit 0

0 commit comments

Comments
 (0)