OS X - Create Hardware report SPX and save it to a AFP share

02-06-2013 | Remy van Elst


Table of Contents


This script creates a OS X hardware report (an SPX file) and saves it to a AFP share. This is usefull when you are rolling out new machines. Run this script via Apple Remote Desktop and you have all your administration in your AFP share, which you can later put in your CMDB. The report has all the hardware data, from firmware, serial number, model, MAC addresses, disk and memory information, in short everything you need for your CMDB and support contracts.

This is the script:

#!/bin/bash
mkdir /Volumes/hardware-report/;
mount -t afp afp://AFPUSER:AFPPASSWORD@10.2.38.1/Hardware /Volumes/hardware-report;
mkdir -p "/Volumes/hardware-report/`hostname -s`";
system_profiler -detailLevel full -xml > "/Volumes/hardware-report/`hostname -s`/Report-for-`hostname -s`.spx";
umount /Volumes/hardware-report;
unlink $0

Change the username, password, share IP/Hostname and share path. Then copy it to all the machines via Apple Remote Desktop, in the /tmp folder. Now via ARD execute it as root. You should see new folder appear in the AFP share based on the machine hostname. In there you find the .SPX files which you can use for your administration.

Note that the last line, unlink $0 removes the script after it ran. So the username and password don't stay on the machine.


Tags: afp, apple, apple-remote-desktop, ard, cmdb, hardware-report, mac, os-x, sleep,