Vigencia de garantía AppleCare en Mac
Lee del propio macOS la fecha en que termina la cobertura de AppleCare y la reporta como atributo personalizado en Intune. No consulta a Apple.
Ejemplo en México
Estudio de diseño en Ciudad de México, 25 Mac
Quieren saber qué Mac pierden garantía este año para presupuestar renovación o cobertura.
check-applecare-warranty-status.shVe 6 Mac con "Expired" y 4 que vencen en el trimestre, y las incluye en el plan de compras.
Cómo implementarlo
- En el centro de administración de Microsoft Intune ve a Dispositivos > Por plataforma > macOS > Organizar dispositivos > Atributos personalizados para macOS (Custom attributes for macOS) > Agregar.
- Ponle nombre al perfil, elige el tipo de dato String y sube el archivo check-applecare-warranty-status.sh.
- Asígnalo a un grupo piloto de Mac. Intune ejecuta el script cada 8 horas y reporta lo que imprime.
- Revisa el resultado por dispositivo en Atributos personalizados > tu perfil > Estado del dispositivo y programa la renovación de los equipos que dicen Expired.
Ver el código completo de check-applecare-warranty-status.sh
#!/bin/bash
# TITLE: Check AppleCare Warranty Status
# SYNOPSIS: Checks Apple warranty and AppleCare status on macOS devices
# DESCRIPTION: This script checks the warranty status of Apple devices by reading the local
# warranty information stored by macOS. It retrieves the coverage end date
# and displays it in a user-friendly format. The script is designed to work
# with Intune-managed macOS devices as a custom attribute.
# TAGS: Monitoring,Device
# PLATFORM: macOS
# MIN_OS_VERSION: 10.15
# AUTHOR: Ugur Koc
# VERSION: 1.0
# LASTUPDATE: 2025-06-02
# CHANGELOG:
# 1.0 - Initial release
#
# EXAMPLE:
# ./check-applecare-warranty-status.sh
# Checks the warranty status and outputs coverage expiration dates
#
# NOTES:
# - Script reads warranty information from macOS system files
# - No external dependencies required
# - Designed for Intune custom attributes (single line output)
# - Works when run as root or user context
# - For more scripts and guides, visit: IntuneMacAdmins.com
# - Source: https://community.jamf.com/t5/jamf-pro/collecting-warranty-status/m-p/298357#M263560
# ============================================================================
# VARIABLES AND INITIALIZATION
# ============================================================================
# Function to check warranty for a specific user
check_user_warranty() {
local user_home="$1"
local warrantyDir="$user_home/Library/Application Support/com.apple.NewDeviceOutreach"
# Check if the directory exists
if [ ! -d "$warrantyDir" ]; then
return 1
fi
# Find warranty files
local warrantyFiles
warrantyFiles=$(find "$warrantyDir" -maxdepth 1 -name "*_Warranty*" -type f 2>/dev/null)
if [ -z "$warrantyFiles" ]; then
return 1
fi
# Get the most recent warranty file
local latestFile
latestFile=$(echo "$warrantyFiles" | xargs ls -t 2>/dev/null | head -n1)
if [ -z "$latestFile" ]; then
return 1
fi
# Read the coverage end date
local expires
expires=$(defaults read "$latestFile" coverageEndDate 2>/dev/null || echo "")
if [ -n "$expires" ]; then
# Convert epoch to ISO-8601 format for better compatibility
local ACexpires
ACexpires=$(date -r "$expires" '+%Y-%m-%d' 2>/dev/null || echo "")
if [ -n "$ACexpires" ]; then
# Check if warranty has expired
local currentDate
currentDate=$(date +%s)
if [ "$expires" -lt "$currentDate" ]; then
echo "Expired: $ACexpires"
else
echo "Expires: $ACexpires"
fi
return 0
fi
fi
return 1
}
# ============================================================================
# MAIN SCRIPT LOGIC
# ============================================================================
# Try to get warranty information
# First, try the current console user
loggedInUser=$(stat -f "%Su" /dev/console 2>/dev/null)
if [ -n "$loggedInUser" ] && [ "$loggedInUser" != "root" ] && [ "$loggedInUser" != "_windowserver" ]; then
# Check logged in user's warranty
userHome=$(dscl . -read /Users/"$loggedInUser" NFSHomeDirectory 2>/dev/null | awk '{print $2}')
if [ -n "$userHome" ] && [ -d "$userHome" ]; then
result=$(check_user_warranty "$userHome")
if [ -n "$result" ]; then
echo "$result"
exit 0
fi
fi
fi
# If no console user or warranty not found, check all user directories
for userHome in /Users/*; do
# Skip system directories
if [[ "$userHome" == "/Users/Shared" ]] || [[ "$userHome" == "/Users/Guest" ]]; then
continue
fi
if [ -d "$userHome" ]; then
result=$(check_user_warranty "$userHome")
if [ -n "$result" ]; then
echo "$result"
exit 0
fi
fi
done
# If we get here, no warranty information was found
echo "No warranty information"
exit 0
# Copia sin cambios de https://github.com/ugurkocde/IntuneAutomation (commit 797bb2e).
# MIT License
#
# Copyright (c) 2025 Ugur Koc | Microsoft MVP
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.