diff --git a/Computer Information.bash b/Computer Information.bash
index def22dc..bb71561 100755
--- a/Computer Information.bash
+++ b/Computer Information.bash
@@ -154,7 +154,7 @@ operatingSystem="Operating System: $runCommand"
# Display battery cycle count
-runCommand=$( /usr/sbin/ioreg -r -c "AppleSmartBattery" | /usr/bin/grep -w "CycleCount" | /usr/bin/awk '{print $3}' | /usr/bin/sed s/\"//g )
+runCommand=$( /usr/sbin/ioreg -r -c AppleSmartBattery | /usr/bin/awk '$1=="\"CycleCount\"" {print $3}' )
batteryCycleCount="Battery Cycle Count: $runCommand"
diff --git a/ReportOfficeLicense.sh b/ReportOfficeLicense.sh
index 1629ed1..988afe7 100755
--- a/ReportOfficeLicense.sh
+++ b/ReportOfficeLicense.sh
@@ -26,7 +26,6 @@
"Communication happens when I know that you know what I know."
INSTRUCTIONS
-
1) Log in to the Jamf Pro server.
2) In Jamf Pro navigate to Settings > Computer Management > Extension Attributes.
3) Click the " + " button to create a new extension attribute with these settings:
@@ -71,6 +70,7 @@ function DetectPerpetualLicense {
}
function DetectO365License {
+
# 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 }' )
@@ -97,22 +97,83 @@ function DetectO365License {
echo $activations
}
+function DetectAppStoreInstall {
+
+ # checks the MAS receipt for each Office app
+ if [[ -d "/Applications/Microsoft Excel.app/Contents/_MASReceipt" ]]; then
+ masReceipt[0]="Excel"
+ fi
+ if [[ -d "/Applications/Microsoft Outlook.app/Contents/_MASReceipt" ]]; then
+ masReceipt[1]="Outlook"
+ fi
+ if [[ -d "/Applications/Microsoft PowerPoint.app/Contents/_MASReceipt" ]]; then
+ masReceipt[2]="PowerPoint"
+ fi
+ if [[ -d "/Applications/Microsoft Word.app/Contents/_MASReceipt" ]]; then
+ masReceipt[3]="Word"
+ fi
+
+ # returns the list of Mac App Store versions if any is installed
+ if [[ "${masReceipt[@]}" ]]; then
+ echo "Mac App Store versions installed (${masReceipt[@]})"
+ fi
+}
+
+function DetectInstalledVersions {
+
+ # checks app versions
+ appList=(Excel,Outlook,PowerPoint,Word)
+
+ IFS=$','
+ for i in ${appList}; do
+ if [[ -f "/Applications/Microsoft $i.app/Contents/Info.plist" ]]; then
+ appVersion=$(defaults read "/Applications/Microsoft $i.app/Contents/Info.plist" CFBundleVersion | awk -F '.' '{print $2}')
+ if [ ${appVersion} -gt 16 ]; then
+ lastVersionCount=$((lastVersionCount+1))
+ fi
+ fi
+ done
+
+ # returns the count of Office 2019 installed apps
+ echo $lastVersionCount
+}
+
## Main
PLPresent=$(DetectPerpetualLicense)
O365Activations=$(DetectO365License)
+AppStorePresent=$(DetectAppStoreInstall)
+LastVersionInstalled=$(DetectInstalledVersions)
-if [ "$PLPresent" != "No" ] && [ "$O365Activations" ]; then
- echo "$PLPresent and Office 365 licenses detected. Only the $PLPresent license will be used."
+if [ ! "$AppStorePresent" ]; then
+
+ if [ "$PLPresent" != "No" ] && [ "$O365Activations" ]; then
+ if [ "$LastVersionInstalled" -ge 1 ] ; then
+ echo "$PLPresent and Office 365 licenses detected. Last versions of apps will use Office 365."
+
+ else
+ echo "$PLPresent and Office 365 licenses detected. Only the $PLPresent license will be used."
+ fi
-elif [ "$PLPresent" != "No" ]; then
- echo "$PLPresent license"
+ elif [ "$PLPresent" != "No" ]; then
+ echo "$PLPresent license"
-elif [ "$O365Activations" ]; then
- echo "Office 365 activations: $O365Activations"
+ elif [ "$O365Activations" ]; then
+ echo "Office 365 activations: $O365Activations"
-elif [ "$PLPresent" == "No" ] && [ ! "$O365Activations" ]; then
- echo "No licenses"
+ elif [ "$PLPresent" == "No" ] && [ ! "$O365Activations" ]; then
+ echo "No licenses"
+ fi
+
+else
+
+ if [ "$O365Activations" ]; then
+ echo "Office 365 activations: $O365Activations, with $AppStorePresent"
+
+ else
+ echo "No licences but $AppStorePresent"
+ fi
+
fi
-exit 0
\ No newline at end of file
+exit 0