# Script to retrieve System Information on Mac

The System Information app is the information hub where all the detailed specifications and information regarding a macOS device can be viewed. As a system admin, there may occur situations where you need to gather necessary information about your Mac endpoints from the System Information app. Using Hexnode’s [Execute Custom Script](https://www.hexnode.com/mobile-device-management/help/how-to-run-scripts-on-mac-using-hexnode-mdm/) action, you can remotely retrieve all the required information using the shell command detailed in this document.

 Disclaimer: 
The Sample Scripts provided below are adapted from third-party Open-Source sites.

 

Retrieve Mac’s System Information
---------------------------------

Script to retrieve system information on Mac

system\_profiler 

   1

  system\_profiler 

   

 

  

The *system\_profiler* command will create a complete report of the Mac’s *System Information*. After successfully executing the above command, you can view the system report by navigating to **Action History** on the device summary page and clicking *Show Output*.

If you need only the information about specific system hardware or software, running the *system\_profiler* command alone would not be very efficient as it can be time-consuming, especially if the device is slow or has an older OS version. Instead, you can run a more specific command by specifying the required *Data Type*.

To get a list of all the available data types associated with a Mac, you can invoke the *listDataTypes* argument along with the *system\_profiler* command:

Script to list all the available data types

system\_profiler –listDataTypes 

   1

  system\_profiler –listDataTypes 

   

 

  

You can then specify the required *Data Type* in the **Arguments** space when running the following command from the Hexnode portal:

Script to retrieve specific system information on Mac

system\_profiler $1 #the argument $1 can take the value of any Data Type 

   1

2

  system\_profiler $1

\#the argument $1 can take the value of any Data Type 

   

 

  

For example, to get information about the audio devices associated with a Mac, `SPAudioDataType` can be entered as the argument while executing the script from the Hexnode portal. Alternatively, you can run the following command directly:

`system_profiler SPAudioDataType `

Below are a few arguments that you can use to fetch specific information about the Mac:

Argument Retrieved InformationSPHardwareDataTypeHardware overviewSPSoftwareDataType System software information SPBluetoothDataType Bluetooth devices associated with the MacSPUSBDataType List all USB devices associated with the Mac SPDisplaysDataTypeGraphics card (GPU) informationSPStorageDataType Information about the Mac’s storage drives SPPrefPaneDataTypeInformation about the different *System Preferences* panesScript to save the *System Information* report
----------------------------------------------

To save the system information report in a text-based file on your Mac endpoint, run the below command.

Script to save the system information

system\_profiler > enter\_the\_path\_here/report\_name.txt 

   1

  system\_profiler > enter\_the\_path\_here/report\_name.txt 

   

 

  

 Notes:- It is recommended to manually validate the script execution on a system before executing the action in bulk.
- Hexnode will not be responsible for any damage/loss to the system on the behavior of the script.