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:

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

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 $commandThis 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 asget_serial.shand 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:
- Set the Default Printer Using PowerShell in Windows
- Set Password for Local User in Windows 11 Using PowerShell
- Set the Time Zone Using PowerShell in Windows
- Get Your MacBook Pro Model Number Using PowerShell
- Get MacBook Pro Battery Health Using PowerShell
Bijay Kumar is an esteemed author and the mind behind PowerShellFAQs.com, where he shares his extensive knowledge and expertise in PowerShell, with a particular focus on SharePoint projects. Recognized for his contributions to the tech community, Bijay has been honored with the prestigious Microsoft MVP award. With over 15 years of experience in the software industry, he has a rich professional background, having worked with industry giants such as HP and TCS. His insights and guidance have made him a respected figure in the world of software development and administration. Read more.