Invoke the system_profiler tool and parse its output; use something like "system_profiler -xml SPHardwareDataType".