Command line to show the AppleCare Status and expirate date for the mac

sfiguet
New Contributor III

Hello,

I search if somebody knows where these informations are written in the mac. I don't find command line or path to import it. My purpose is to create an extension attribute in JamfPro with these data.

If somebody could help me. :-)

Capture d’écran 2022-11-28 à 13.39.48.png

1 ACCEPTED SOLUTION

YanW
Contributor III

You can check out the 

~/Library/Application\ Support/com.apple.NewDeviceOutreach/Warranty.plist

View solution in original post

11 REPLIES 11

nelsoni
Contributor III

I am sure there are people who know how to do this, but my assumption would be that this is solved by setting up the GSX integration in Jamf. It is basic info it pulls and it must be done manually but it does work.

YanW
Contributor III

You can check out the 

~/Library/Application\ Support/com.apple.NewDeviceOutreach/Warranty.plist

jamf-42
Valued Contributor II

Testing this prior to coding an EA. Ive noticed that on 'some' devices, the folder /com.apple.NewDeviceOutreach does not exist.. and of course then nor the plist.. when looking at system settings I see this dialog.. pretty sure no one has invoked this..  so do we know how this is created?Screenshot 2022-12-02 at 11.02.45.png

 

sfiguet
New Contributor III

@YanW Do you know how (and when) the folder /com.apple.NewDeviceOutreach is created ? I have the same issue, some computers don't have it. (and I don't know why... :-) ).

 

YanW
Contributor III

I'm not sure either, hope someone can answer it. I found THIS which need a bit of work. 

sfiguet
New Contributor III

Perfect ! I do two extension attributes. One for the status (covered or not) and another one for the expiration date. Thank you !

Malcolm
Contributor II

I suspect the existence of the folder might only be available to the account first setup with the device. I am waiting to come across a device I can potentially identify this to be true.

if the were generate one with similar info under /library then this would be easier to code with.

edwin_henley
New Contributor

I believe the warranty.plist is created for any user who checks the warranty of the system from the system.  They would browse to the warranty lookup Apple Portal and provide the systems serial number https://checkcoverage.apple.com/ whatever user is logged in will then have the warranty.plist written in the context of their login

Malcolm
Contributor II

I have 510 reports of AC+ information now of 1400+ devices

I believe the reporting factor is actually who has an iCloud account signed in and who doesn't as I have checked coverage on a device that has no iCloud signed in and it would not report the information required. It's plausible that AC+ might have to be current for it to come through though.

seems I also had to go to Apple > about this Mac > support tab for it to populate, but I am fairly confident that many of the examples I have would never had done that step, so quite possibly it could have generated this step on its own at some over stage.

I am keeping an eye out for devices from this point to see if they have iCloud signed in, as to confirm the main contributing factor.

Malcolm
Contributor II

I worked up this, to run weekly for all devices devices but will only notify where the expiry occurs within 60 days (to compensate for our larger holiday periods) the AppleScript notification in there does need some pppc profile modification of security features for it to run and display a prompt.

 

loggedInUser=$( echo "show State:/Users/ConsoleUser" | scutil | awk '/Name / { print $3 }' )
# Find the coverage end date key in Warranty.plist
coverageEndDate=$( /usr/bin/defaults read /Users/$loggedInUser/Library/Application\ Support/com.apple.NewDeviceOutreach/Warranty.plist coverageEndDate )
# Format the EPOCH time to something readable
formattedTime=$(date -jf %s $coverageEndDate "+%F %T")

# Get the current date
current_date=$(date +"%Y-%m-%d")

# The date to check
date_to_check=$formattedTime

# Convert the dates to Unix timestamps
current_date_timestamp=$(date -j -f "%Y-%m-%d" "$current_date" +%s)
date_to_check_timestamp=$(date -j -f "%Y-%m-%d" "$date_to_check" +%s)

# Calculate the difference between the two dates in days
days_diff=$((($date_to_check_timestamp - $current_date_timestamp) / 86400))

# Check if the date to check is 30 days greater than the current date
if [[ $days_diff -ge 1 && $days_diff -le 60 ]]; then
  # Report the date
  echo "result: $date_to_check"

  # Add debug print statements
#  echo "current_date: $current_date"
#  echo "date_to_check: $date_to_check"
#  echo "date_diff: $date_diff"
#  echo "days_diff: $days_diff"

fi
if [[ $days_diff -ge 1 && $days_diff -le 60 ]]; then
strmessage=""
# Discover logged in user
strmessage=$(sudo -u $3 /usr/bin/osascript << EOF
try
set theResponse to display dialog "Our Management Software has identified your AppleCare+ coverage for your Macbook, will expire:
$formattedTime

If there is any known damage or issues with your Macbook you want to address, we would encourage you to visit our IT Staff, to discuss your concerns, while the device is still eligible for AppleCare+.

Not All devices report their AppleCare+ and we encourage users to check their own AppleCare+ via https://checkcoverage.apple.com

This message will appear weekly Until your Coverage Expires.

ORGANISATION NAME" with hidden answer with icon note buttons {"Continue"} default button "Continue"
--> {button returned:"Continue", text returned:""}
return text returned of theResponse
end try
EOF)
fi