Thanks, I have already checked these. unfortunately, they don't work for the current macOSYou can get the internal model name eg "Macmini5,2" from running "sysctl -n hw.model".
To translate that into model year requires some extra effort; see some discussion of that at: https://apple.stackexchange.com/que...el-year-be-determined-with-a-terminal-command
Code:system_profiler SPHardwareDataType
defaults read ~/Library/Preferences/com.apple.SystemProfiler.plist 'CPU Names' | cut -sd '"' -f 4 | uniq
You should probably consider reinstalling macOS, as the current installed one doesn’t properly recognize your MacBook.@NoBoMac - the code you provided returns "MacBook Pro (13-inch, M1, 2020)" on my 2022 M2 MacBook Air, so it doesn't seem reliable.
this is what it outputs for me:^^Kewl!
From that thread, looks like the following is pretty straight forward/easy.Not quite what About This Mac returns, but close enough imo.Returned exactly what is in About this Mac for me.
Code:defaults read ~/Library/Preferences/com.apple.SystemProfiler.plist 'CPU Names' | cut -sd '"' -f 4 | uniq
The command works fine on all Macs, but only if System Profiler has been run in the GUI, on that particular computer. Running system_profiler at the command line will not generate that preference file. It'd seem like there's a chance the file will have the wrong data if Migration Assistant was used and System Profiler hasn't been run on the current system.this is what it outputs for me:
View attachment 2035625
This is what it outputs for my coworker:
View attachment 2035630
I have an M1, he does not. How can we tweak the script for M1?
Can you show me how to do that? thanks so muchThe command works fine on all Macs, but only if System Profiler has been run in the GUI, on that particular computer. Running system_profiler at the command line will not generate that preference file. It'd seem like there's a chance the file will have the wrong data if Migration Assistant was used and System Profiler hasn't been run on the current system.
Show you how to do what? You'd have to have opened up the System Report app in the GUI for the preference file referenced in that command to exist.Can you show me how to do that? thanks so much
i guess how to open that in GUI. I'm new to this so its a bit confusing.Show you how to do what? You'd have to have opened up the System Report app in the GUI for the preference file referenced in that command to exist.
Hold the option key, click on the Apple menu, select the first item, "System information..." or go to the Apple menu, choose "About this Mac" and then click System Report.i guess how to open that in GUI. I'm new to this so its a bit confusing.
So sorry for the back and forth. We are trying to do 0 touch deployment and need this information for inventory keeping. It worked for one person who doesn't have M1 chip. For the rest of our team with an M1 chip it doesn't work it pulls this up.Hold the option key, click on the Apple menu, select the first item, "System information..." or go to the Apple menu, choose "About this Mac" and then click System Report.
This command, as written, also requires that you're running it as the logged in user, so if you're trying to get this info remotely it's also potentially going to fail.
This isn't going to work in a zero touch deployment. Your MDM system should easily collect this data and report on it; I would use that rather than trying to come up with another way to do the same job.So sorry for the back and forth. We are trying to do 0 touch deployment and need this information for inventory keeping. It worked for one person who doesn't have M1 chip. For the rest of our team with an M1 chip it doesn't work it pulls this up. View attachment 2035641
You could get Model Identifier with system_profiler and convert that into your desired format into the inventory database.So sorry for the back and forth. We are trying to do 0 touch deployment and need this information for inventory keeping.
system_profiler SPHardwareDataType | grep "Model Identifier:" | sed -e s/" Model Identifier: "//
On the computer I tried, the file was regenerated when opening System Information and then quitting it. Aside from the file not necessarily existing, I don't think it's a reliable data source for this information. The file can also be manually edited and that edit remains indefinitely.@chrfr - I checked the com.apple.SystemProfiler.plist file for my system and it was dated back in 2020, so must have migrated over from my M1 MacBook Pro, so I dropped it into the Trash. I then ran System Information and no new plist was created. I clicked on Updates and it took me into System Preferences and checked for an update and after that I had a new com.apple.SystemProfiler.plist, but it was much smaller than the original.
I then re-executed the terminal command, "defaults read ~/Library/Preferences/com.apple.SystemProfiler.plist 'CPU Names' | cut -sd '"' -f 4 | uniq" but it tells me that CPU Names doesn't exist.
Next, I went back into System Information and under the File menu there was an option to refresh the list, which I did and this resulted in a plist file that was about twice as large as the previous version, but still about half the size of the original and the defaults read command still can't find CPU Names.
Do you have any idea on how to get my system to regenerate the full SystemProfiler.plist file? It's not a big deal, but I'm wondering if I'm doing something wrong.
The computer I used to test is an M1 Mini, running 12.5, so it's also on that same version of System Information, and it does write the CPU name in a new copy of the file if I delete it, but again, this is so unreliable and depends on the GUI to even have a chance of working, so it can't solve the OP's issue.Thanks @chrfr !
What I've found is that the com.apple.SystemProfiler.plist on seems to contain only window position information now. There is no other information in the file when I just perform a defaults read with no parameters. This makes sense to me as it's this type of info that plist files were really intended to contain.
I'm thinking that older versions of System Information wrote more data here, but the current one, V11.0, does not.