Extension Attribute to pull monitor resolution?

donmontalvo
Esteemed Contributor III

I know ARD can do this...does anyone know how to make an Extension Attribute to pull the monitor resolution?

Thanks in advance! :)

Don

--
https://donmontalvo.com
7 REPLIES 7

lance_ogletree
Contributor
Contributor

system_profiler SPDisplaysDataType | grep Resolution

Will get you your resolution. You can pop this into a script for a custom
extension attribute.

Still some work needed on your part for the script, but this gets you down
to where you want to look for the display(s) resolution(s)

-Lance

--
Lance Ogletree
Systems Engineer
Mobile: (972) 342-5990
Direct: (972) 547-9566
lance.ogletree at jamfsoftware.com
lanceo at mac.com(iChat)
....................................................................
JAMF Software
1011 Washington Ave. S
Suite 350
Minneapolis, MN 55415
....................................................................
Office: (612) 605-6625
Facsimile: (612) 332-9054
....................................................................
US Support: (612) 216-1296
....................................................................
http://www.jamfsoftware.com <http://www.jamfsoftware.com/>

donmontalvo
Esteemed Contributor III

Thanks Lance,

Google is your friend...

http://discussions.apple.com/thread.jspa?threadID=2721442&tstart=60

Here's the command to pull the current resolution of monitor(s):

system_profiler SPDisplaysDataType | awk -F: '/Resolution/ {print $2}'

I guess I'll need to cobble together the Extension Attributes...one moment while I roll up my sleeves...

Don

--
https://donmontalvo.com

donmontalvo
Esteemed Contributor III

This did the trick:

---------------------------------
#!/bin/sh
echo "<result>/usr/sbin/system_profiler SPDisplaysDataType | awk -F: '/Resolution/ {print $2}'</result>"
---------------------------------

Thanks,
Don

--
https://donmontalvo.com

tlarkin
Honored Contributor

The only problem with grep is that it can be too broad, and it can grab anything and everything that has the string Resolution in it. If you are running dual displays or hooked up to a projector when it runs this may cause issue. Of course I have not tested it, but for example if I did a grep for connections using port 548 it may grab these ports on a network connection:

1548
33548
153248

Since the string 548 is in all of those you may get wonky results.

just FYI

-Tom

jszaszvari
New Contributor III
New Contributor III

Then just use a regular expression to narrow down your results to what you need..

jszaszvari
New Contributor III
New Contributor III

For anyone that's interested here is a resource on using it

http://www.wellho.net/regex/grep.html

http://www.robelle.com/smugbook/regexpr.html

Cheers
John

GabeShack
Valued Contributor III

Tweaked this extension attribute a bit so it will also pull windows machines screen resolutions as well. Just paste this in the VBScript field after doing the above for the mac:

Set objWMIService = GetObject("Winmgmts:. ootcimv2") Set colItems = objWMIService.ExecQuery("Select * From Win32_DesktopMonitor where DeviceID = 'DesktopMonitor1'",,0) For Each objItem in colItems intHorizontal = objItem.ScreenWidth intVertical = objItem.ScreenHeight Next
WScript.Echo "<result>" &amp; intHorizontal&amp;"x"&amp;intVertical &amp; "</result>"

Gabe Shackney
Princeton Public Schools