Skip to content

Commit

Permalink
Merge pull request #4 from grahampugh/master
Browse files Browse the repository at this point in the history
Update Office_License.sh
  • Loading branch information
pbowden-msft authored Jan 27, 2021
2 parents 9a57a82 + 1171fe1 commit 9f737ca
Showing 1 changed file with 29 additions and 36 deletions.
65 changes: 29 additions & 36 deletions Office_License.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
#!/bin/bash

<<ABOUT_THIS_SCRIPT
: <<ABOUT_THIS_SCRIPT
-----------------------------------------------------------------------
Written by: Paul Bowden
Expand Down Expand Up @@ -50,7 +50,7 @@ ABOUT_THIS_SCRIPT
PERPETUALLICENSE="/Library/Preferences/com.microsoft.office.licensingV2.plist"

# Detects the presence of a perpetual license
function DetectPerpetualLicense {
DetectPerpetualLicense() {
if [ -f "$PERPETUALLICENSE" ]; then
/bin/echo "Yes"
else
Expand All @@ -59,52 +59,45 @@ function DetectPerpetualLicense {
}

# Determines what type of perpetual license the machine has installed
function PerpetualLicenseType {
PerpetualLicenseType() {
if [ -f "$PERPETUALLICENSE" ]; then
/bin/cat "$PERPETUALLICENSE" | /usr/bin/grep -q "A7vRjN2l/dCJHZOm8LKan11/zCYPCRpyChB6lOrgfi"
if [ "$?" == "0" ]; then
/bin/echo "Office 2019 Volume License"
return
if /usr/bin/grep -q "A7vRjN2l/dCJHZOm8LKan11/zCYPCRpyChB6lOrgfi" "$PERPETUALLICENSE"; then
/bin/echo "Office 2019 Volume License"
return
fi
/bin/cat "$PERPETUALLICENSE" | /usr/bin/grep -q "Bozo+MzVxzFzbIo+hhzTl4JKv18WeUuUhLXtH0z36s"
if [ "$?" == "0" ]; then
/bin/echo "Office 2019 Preview Volume License"
return
if /usr/bin/grep -q "Bozo+MzVxzFzbIo+hhzTl4JKv18WeUuUhLXtH0z36s" "$PERPETUALLICENSE"; then
/bin/echo "Office 2019 Preview Volume License"
return
fi
/bin/cat "$PERPETUALLICENSE" | /usr/bin/grep -q "A7vRjN2l/dCJHZOm8LKan1Jax2s2f21lEF8Pe11Y+V"
if [ "$?" == "0" ]; then
/bin/echo "Office 2016 Volume License"
return
if /usr/bin/grep -q "A7vRjN2l/dCJHZOm8LKan1Jax2s2f21lEF8Pe11Y+V" "$PERPETUALLICENSE"; then
/bin/echo "Office 2016 Volume License"
return
fi
/bin/cat "$PERPETUALLICENSE" | /usr/bin/grep -q "DrL/l9tx4T9MsjKloHI5eX"
if [ "$?" == "0" ]; then
/bin/echo "Office 2016 Home and Business License"
return
if /usr/bin/grep -q "DrL/l9tx4T9MsjKloHI5eX" "$PERPETUALLICENSE"; then
/bin/echo "Office 2016 Home and Business License"
return
fi
/bin/cat "$PERPETUALLICENSE" | /usr/bin/grep -q "C8l2E2OeU13/p1FPI6EJAn"
if [ "$?" == "0" ]; then
/bin/echo "Office 2016 Home and Student License"
return
if /usr/bin/grep -q "C8l2E2OeU13/p1FPI6EJAn" "$PERPETUALLICENSE"; then
/bin/echo "Office 2016 Home and Student License"
return
fi
/bin/cat "$PERPETUALLICENSE" | /usr/bin/grep -q "Bozo+MzVxzFzbIo+hhzTl4m"
if [ "$?" == "0" ]; then
/bin/echo "Office 2019 Home and Business License"
return
if /usr/bin/grep -q "Bozo+MzVxzFzbIo+hhzTl4m" "$PERPETUALLICENSE"; then
/bin/echo "Office 2019 Home and Business License"
return
fi
/bin/cat "$PERPETUALLICENSE" | /usr/bin/grep -q "Bozo+MzVxzFzbIo+hhzTl4j"
if [ "$?" == "0" ]; then
/bin/echo "Office 2019 Home and Student License"
return
if /usr/bin/grep -q "Bozo+MzVxzFzbIo+hhzTl4j"; then
/bin/echo "Office 2019 Home and Student License"
return
fi
/bin/echo "Office Perpetual License"
fi
}

# Creates a list of local usernames with UIDs above 500 (not hidden)
function DetectO365License {
DetectO365License() {
userList=$( /usr/bin/dscl /Local/Default -list /Users uid | /usr/bin/awk '$2 >= 501 { print $1 }' )

while IFS= read aUser
while IFS= read -r aUser
do
# get the user's home folder path
homePath=$( eval /bin/echo ~$aUser )
Expand All @@ -116,7 +109,7 @@ function DetectO365License {
O365SUBBAK2="$homePath/Library/Group Containers/UBF8T346G9.Office/O4kTOBJ0M5ITQxATLEJkQ40SNwQDNtQUOxATL1YUNxQUO2E0e" # hidden file

# checks to see if an O365 subscription license file is present for each user
if [[ -f "$O365SUBMAIN" || -f "$O365SUBBAK1" || -f "$O365SUBBAK2" || -d "$O365SUBNEW" ]]; then
if [ -f "$O365SUBMAIN" ] || [ -f "$O365SUBBAK1" ] || [ -f "$O365SUBBAK2" ] || [ -d "$O365SUBNEW" ]; then
activations=$((activations+1))
fi
done <<< "$userList"
Expand Down Expand Up @@ -144,4 +137,4 @@ elif [ "$PERPETUALPRESENT" == "No" ] && [ ! "$O365ACTIVATIONS" ]; then
/bin/echo "<result>No license</result>"
fi

exit 0
exit 0

0 comments on commit 9f737ca

Please sign in to comment.