Relevance script for Mac OS X

(imported topic written by SystemAdmin)

Hi,

Any kind soul out there are able to post some sample relevance script for Mac OS X

My requirement is to capture all the installed applications name and its version residing in default /Applications folder

Thanks,

(imported comment written by jessewk)

Hi shsshs,

In the BES Inventory and Analysis site there is an analysis called ‘Application Information (Mac OS X)’ that contains the following properties:

Number of Non-System Applications

Number of System Applications

Number of Running Carbon Porcesses

Number of Runing Non-Carbon Processes

Running Processes

Installed Applications

Default Web Browser

You can use the Installed Applications property or modify it slightly to restrict it to only apps in the Applications folder.

Jesse

(imported comment written by SystemAdmin)

Yes I did,it reported all the applications. How about the versioning ?

for example,Apple quicktime player and some other apps did not give the version info

(imported comment written by jessewk)

You could create a retrieved property with this definition:

(name of it, (if exists version of it then version of it as string else “”)) of applications

However, note that this an expensive property (lots of results, most of them unique). If you do create the above property you should set it to only evaluate once per day (default is every report). The properties in the analysis are already set to report once a day. Also, you should avoid leaving both the analysis property and the custom property activated at the same time since they retrieve the same info.

-Jesse

(imported comment written by SystemAdmin)

Hi Jesse,

Thanks for your help,the script works fine except how to filter just report the “\Applications” folder instead of all apps in the .\Volume,thks

(imported comment written by jessewk)

This is the easy way:

(name of it, (if exists version of it then version of it as string else “”)) of applications whose (pathname of it starts with “/Applications”)

But this will work even if the OS is in a different language:

(name of it, (if exists version of it then version of it as string else “”)) of applications whose (pathname of it starts with pathname of applications folder)

(imported comment written by SystemAdmin)

I’ve encountered some version issue here,the above only returns the CFBundleVersion and many times it is not the correct apps version. Instead,how to get the CFBundleGetInfoString info from a apps ?

thks,

(imported comment written by jessewk)

Ah yes, the wonders of versioning on Mac OS X.

Here are a couple more variations to try. You’ll probably want to mix them up a little:

(name of it, (if exists version of it then version of it as string else “”), (if exists bundle version of it then bundle version of it as string else “”)) of applications whose (pathname of it starts with pathname of applications folder)

(name of it, (if exists version of it then version of it as string else “”), (if exists bundle version of it then bundle version of it as string else “”), (if exist folder (pathname of it) AND exists string “CFBundleGetInfoString” of global dictionary of bundle of folder (pathname of it) then string “CFBundleGetInfoString” of global dictionary of bundle of folder (pathname of it) else “”)) of applications whose (pathname of it starts with pathname of applications folder)

Note that there are several other places that version can be stored in a bundle, including CFBundleShortVersionString, SourceVersion, and BuildVersion.

When Apple’s Installer checks for versions, it uses the following logic (and BigFix does the same):

To create a version from a version.plist file, Installer computes a 5-tuple from three keys in the "version.plist file: the CFBundleShortVersionString key, the SourceVersion key, and the BuildVersion key. For a 5-tuple of the form a.b.c.d.e, a.b.c is obtained from the value of CFBundleShortVersionString, d is obtained from the value of SourceVersion, and e is obtained from the value of BuildVersion. If any key is missing, the corresponding element is replaced with 0.

The fourth and fifth elements of the 5-tuple are created from the integer values of SourceVersion and BuildVersion. If the only difference between two submissions is that the SourceVersion field changed from 1.8.4GMc2 to 1.8.4GMc3, Installer treats them as the same because the integer values of both of these is 1. For Installer to be able to distinguish between two copies of a bundle, either the SourceVersion needs to change for each submission, or the CFBundleShortVersionString needs to change, such that the integer values can be differentiated.

(imported comment written by SystemAdmin)

Hi Jesse,

This gave a meaningful result,thks for all your expertise advice.

Another question,I need a relevance script to just only reports Mac client with Adobe and Microsoft products installed and their respective version,can this be done ? Thanks,

(imported comment written by jessewk)

Hi shsshs,

You would just need to adjust the whose clause at the end. For example:

(…) of applications whose (pathname of it starts with pathname of applications folder AND (name of it contains “Adobe” OR name of it contains “Microsoft”))

You can add more OR clauses as necessary to filter down to the particular apps you’re interested in.