Skip to main content
Solved

Determine if Mac is Portable or Desktop via Script?


Forum|alt.badge.img+9

Good afternoon fellow JAMFanatics (TM?) ;)

As I'm sure many of you are, we're stuck deploying Mavericks to the new model MBPs, Airs, and Mac Pros. For our portables, we're getting complaints about the new 'feature' that the user sees in regards to the policy update popup when they log into their Macs and they can't contact the JSS. (For reference: https://jamfnation.jamfsoftware.com/discussion.html?id=8777)

In an effort to curtail that, I'm planning on modifying our standard settings script to disable this check if the machine is a portable. However, I can't seem to find an easy way to determine if it's a portable or desktop. I know system_profiler can be used to pull the model number and whatnot, but I'd rather not try and grep/awk and build a nested if statement if I can help it.

Does anyone know a command or another method to easily return if the machine is a portable? If not, I'll write up a script to determine it and post it here for future reference.

Thank you!

Best answer by rich.trouton

I've used this command to tell me if I'm on a laptop or otherwise:

/usr/sbin/system_profiler SPHardwareDataType | grep "Model Identifier" | grep "Book"

I'm using it here in this script:

https://github.com/rtrouton/rtrouton_scripts/blob/master/rtrouton_scripts/setting_energy_saver_settings/powersettings.sh

View original
Did this topic help you find an answer to your question?

8 replies

Forum|alt.badge.img+31
  • Employee
  • 920 replies
  • Answer
  • March 11, 2014

I've used this command to tell me if I'm on a laptop or otherwise:

/usr/sbin/system_profiler SPHardwareDataType | grep "Model Identifier" | grep "Book"

I'm using it here in this script:

https://github.com/rtrouton/rtrouton_scripts/blob/master/rtrouton_scripts/setting_energy_saver_settings/powersettings.sh


Forum|alt.badge.img+9
  • Author
  • Contributor
  • 39 replies
  • March 11, 2014

@rtrouton, that's a great idea! I wouldn't have though to check for a blank value if it didn't return book. Thank you!


mm2270
Forum|alt.badge.img+16
  • Legendary Contributor
  • 7880 replies
  • March 11, 2014

Or ioreg to do basically the same-

ioreg -rd1 -c IOPlatformExpertDevice | awk -F'["|"]' '/model/{print $4}' | grep "Book"

A script like Rich's or this will be your best bet. The term "Book" would only appear in a laptop, never in a Desktop Mac model.


Forum|alt.badge.img+12
  • Employee
  • 128 replies
  • March 11, 2014

You could also just throw together a Smart Group that looks at the

Hardware Information: Model: is like "book"

bentoms
Forum|alt.badge.img+35
  • Legendary Contributor
  • 4331 replies
  • March 11, 2014

Second what @krichterjr said.

We do the same & have done for an age.

For us, we scope the VPN profile to that group.


Forum|alt.badge.img+23
  • Esteemed Contributor
  • 850 replies
  • March 12, 2014

Third what @krichterjr said.

Model: is like MacBook Pro Model: is like MacBook Air Model: is like MacBook

That will neatly catch everything. Further scoping is left to your own requirements.


Forum|alt.badge.img+12
  • Contributor
  • 529 replies
  • March 20, 2014

In case you want it in a script rather than scoping:

sysctl hw.model

John_Wetter
Forum|alt.badge.img+31
  • Contributor
  • 328 replies
  • March 20, 2014

@krichterjr +1 on that solution, that's what we've always done.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings