How to Get Your MacBook Pro Model Number Using PowerShell

In this tutorial, I will explain how to get your MacBook pro model number using PowerShell. I will run all the PowerShell cmdlets on my personal MacBook Pro laptop.

Below are the different methods.

Method 1: Using system_profiler Command via PowerShell

On macOS, the system_profiler command is the go-to utility for detailed system information, including the model number. PowerShell can invoke this command and parse its output.

How it works

system_profiler SPHardwareDataType returns hardware info including the model identifier and serial number. We’ll run this command inside PowerShell and extract the model number.

PowerShell Script Example

Here is the example:

# Run system_profiler and get hardware info
$hardwareInfo = system_profiler SPHardwareDataType

# Filter to find the Model Identifier line
$modelLine = $hardwareInfo | Where-Object { $_ -match "Model Identifier" }

# Extract the model number from the line
$modelNumber = $modelLine -replace ".*: ", ""

Write-Output "Your MacBook Pro Model Number is: $modelNumber"

This script runs the native macOS system profiler tool, captures its output, and uses PowerShell’s text filtering to isolate the model identifier.

You can see the exact output in the screenshot below:

Get Your MacBook Pro Model Number Using PowerShell

Check out List Scheduled Tasks with PowerShell

Method 2: Using WMI Equivalent on macOS with PowerShell (CIM)

While Windows uses WMI (Windows Management Instrumentation) for system info, macOS doesn’t natively support WMI. However, PowerShell’s CIM cmdlets can sometimes interface with remote systems or local hardware info if compatible.

On macOS, CIM cmdlets aren’t as effective locally, but if you’re managing Macs remotely via SSH or other tools, you can pull info using PowerShell remoting or custom scripts.

For local MacBook Pro info, system_profiler remains the best bet. For remote management, consider combining PowerShell remoting with SSH to run commands like system_profiler remotely.

Check out Get the Current Username in PowerShell on MacBook Pro

Method 3: Using AppleScript in PowerShell to Get Model Info

AppleScript can access system info on Macs, and you can invoke AppleScript commands from PowerShell.

We’ll run an AppleScript command inside PowerShell to get the model identifier.

PowerShell Script Example

Here is an example:

# Define AppleScript command to get model identifier
$appleScript = 'system info'

# Run AppleScript via osascript and capture output
$modelNumber = osascript -e 'do shell script "sysctl -n hw.model"'

Write-Output "Your MacBook Pro Model Number is: $modelNumber"

The sysctl -n hw.model command returns the hardware model identifier on macOS. Running it through AppleScript and capturing the output in PowerShell allows you to get the model number cleanly.

Additional Tips for MacBook Pro Model Identification

  • Check System Information App: You can always find the model number under “About This Mac” > “System Report” > “Hardware Overview” > “Model Identifier.”
  • Use Serial Number Lookup: If you have the serial number, Apple’s support website allows you to check your exact model.
  • Model Number vs. Model Identifier: The model identifier (e.g., MacBookPro15,2) is often used in scripts and automation, while the model number (e.g., A1990) is printed on the device.

Conclusion

In this tutorial, I explained how to find your MacBook Pro model number using PowerShell. I recommend using the system_profiler cmdlet in PowerShell.

You may also like:

100 PowerShell cmdlets download free

100 POWERSHELL CMDLETS E-BOOK

FREE Download an eBook that contains 100 PowerShell cmdlets with complete script and examples.