PowerShell Get MacBook Pro Serial Number

I have been using a MacBook Pro for quite some time. Recently, for warranty, I wanted to get the serial number. You can do this using PowerShell. In this tutorial, I will explain how to get the MacBook Pro serial number using PowerShell.

Can PowerShell Get a MacBook Pro Serial Number Directly?

Let’s clarify a key point: PowerShell is a powerful scripting tool primarily for Windows. If you’re running PowerShell on a Windows device and want to get the serial number of a local Windows PC, it’s easy. However, if you’re managing MacBooks from a Windows environment, you’ll need to use remote management tools or scripts that interface with macOS.

If you’re on the Mac itself, you’ll use Terminal commands. But for organizations using PowerShell for cross-platform management, I’ll show you the best approaches.

Here are a few methods you can try to get the serial number of a Mac laptop.

Method 1: Getting Serial Number on a Mac Locally Using Terminal

The most direct way to get your MacBook Pro’s serial number is through the Terminal app on your Mac.

  • Open Terminal: You can find Terminal in Applications > Utilities or search for it with Spotlight (Cmd + Space, then type “Terminal”).
  • Run the following Serial Number Command, and then you can run the command below. This command queries your Mac’s hardware profile and filters the result to show only the serial number line.
system_profiler SPHardwareDataType | grep "Serial Number"

Once you run the cmdlet, you can see the serial number like in the screenshot below:

PowerShell Get MacBook Pro Serial Number

You can also run the same PowerShell cmdlet in VS Code; you can view the exact output. Here is the screenshot for your reference.

get macbook pro serial number using powershell

Check out Delete User Profiles Using PowerShell in Windows 11

Method 2: Remotely Retrieving Serial Number from MacBooks Using PowerShell and SSH

If you’re an IT admin in a mixed environment, you might want to use PowerShell on Windows to get the serial number from a MacBook Pro remotely. This requires SSH access and credentials.

  • On the MacBook Pro, go to System Settings > General > Sharing. Turn on “Remote Login” (SSH).
  • Run the below PowerShell script:
$username = "macadmin"
$host = "macbookpro.local"
$password = "YourMacPassword"
$command = "system_profiler SPHardwareDataType | grep 'Serial Number'"

$securePassword = ConvertTo-SecureString $password -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential($username, $securePassword)

ssh $username@$host $command

This script uses SSH to connect and run the command on the Mac, returning the serial number to your PowerShell session.

Read Track User Login History on Windows Using PowerShell

Method 3: Using AppleScript or Bash Script from PowerShell

For automation at scale, especially with device enrollment programs, you might need to deploy scripts via MDM (Mobile Device Management) or remotely trigger AppleScript or Bash scripts.

  • AppleScript Example:
    You can wrap the Terminal command in an AppleScript and trigger it via remote tools.
  • Bash Script Example:
    Save the following as get_serial.sh and run it on each Mac:
system_profiler SPHardwareDataType | grep "Serial Number"

I hope this tutorial helps you retrieve the MacBook Pro serial number using PowerShell.

You may also like the following tutorials:

100 PowerShell cmdlets download free

100 POWERSHELL CMDLETS E-BOOK

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