Determine if Mac is Portable or Desktop via Script?

ahambidge
New Contributor II

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!

1 ACCEPTED SOLUTION

rtrouton
Release Candidate Programs Tester

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_setti...

View solution in original post

8 REPLIES 8

rtrouton
Release Candidate Programs Tester

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_setti...

ahambidge
New Contributor II

@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
Legendary Contributor III

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.

krichterjr
Contributor

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

Hardware Information: Model: is like "book"

bentoms
Release Candidate Programs Tester

Second what @krichterjr said.

We do the same & have done for an age.

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

franton
Valued Contributor III

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.

sean
Valued Contributor

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

sysctl hw.model

John_Wetter
Release Candidate Programs Tester

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