From b9b77a583d6b57fe99c97a41ce2eb23cfdfa360b Mon Sep 17 00:00:00 2001 From: Tyler Morgan Date: Fri, 31 Aug 2018 10:09:57 -0400 Subject: [PATCH 1/4] Fixed where cycle count wasn't being populated correctly on 10.14 --- Computer Information.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Computer Information.bash b/Computer Information.bash index def22dc..b1f493e 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=$( ioreg -r -c AppleSmartBattery | awk '$1=="\"CycleCount\"" {print $3}' ) batteryCycleCount="Battery Cycle Count: $runCommand" From 20c0392ca91c611aa1f77b72e3630f97801e1365 Mon Sep 17 00:00:00 2001 From: Tyler Morgan Date: Fri, 31 Aug 2018 10:11:18 -0400 Subject: [PATCH 2/4] Added full path for ioreg --- Computer Information.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Computer Information.bash b/Computer Information.bash index b1f493e..e90b6db 100755 --- a/Computer Information.bash +++ b/Computer Information.bash @@ -154,7 +154,7 @@ operatingSystem="Operating System: $runCommand" # Display battery cycle count -runCommand=$( ioreg -r -c AppleSmartBattery | awk '$1=="\"CycleCount\"" {print $3}' ) +runCommand=$( /usr/sbin/ioreg -r -c AppleSmartBattery | awk '$1=="\"CycleCount\"" {print $3}' ) batteryCycleCount="Battery Cycle Count: $runCommand" From 319b11e281e559c6123fb81773deaed64b1f131e Mon Sep 17 00:00:00 2001 From: Tyler Morgan Date: Fri, 31 Aug 2018 10:52:49 -0400 Subject: [PATCH 3/4] Added full path for awk. --- Computer Information.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Computer Information.bash b/Computer Information.bash index e90b6db..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 | awk '$1=="\"CycleCount\"" {print $3}' ) +runCommand=$( /usr/sbin/ioreg -r -c AppleSmartBattery | /usr/bin/awk '$1=="\"CycleCount\"" {print $3}' ) batteryCycleCount="Battery Cycle Count: $runCommand" From 5aa72be5e11daba6690e48dd1d272848d5ac60df Mon Sep 17 00:00:00 2001 From: Emmanuel Canault <45207371+ecanault@users.noreply.github.com> Date: Mon, 4 Feb 2019 18:41:37 +0100 Subject: [PATCH 4/4] Update ReportOfficeLicense.sh --- ReportOfficeLicense.sh | 81 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 71 insertions(+), 10 deletions(-) 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