Extension Attribute for Parallels Desktop License status

mkremic
New Contributor III

Hi all, just wanted to share an extension attribute I wrote to obtain the license status of a Parallels Desktop installation. It searches for the word "ACTIVE" in the license info for Parallels. Should work for v10 and v9 (and probably backwards compatible to a certain number of versions). Handy to see which computers have an active license for Parallels installed and which ones are deactivated/running on a trial! Hope it helps someone!

Set the data type to "String", Inventory Display to "Extension Attributes" (or whatever you choose) and input type to "Script"

Cheers

#!/bin/bash
result=`sudo prlsrvctl info --license | grep ACTIVE` 

if [ "$result" != "" ]; then
    echo "<result>Active</result>"
else
    echo "<result>Inactive</result>"
fi
11 REPLIES 11

donmontalvo
Esteemed Contributor III

Sorry to hijack an old thread. But we're trying to pull the installed Parallels Desktop.app serial number.

How do we take this:

$ prlsrvctl info --license | grep "serial" | awk '{ print $1 }'
serial="XXX-XXXXX-XXXXX-XXXXX-XXXXX-XXXXX"

And trim the output, so we can have an EA that shows just the serial number:

$ prlsrvctl info --license | grep "serial" | awk '{ print $1 }' | <insert-missing-logic>
XXX-XXXXX-XXXXX-XXXXX-XXXXX-XXXXX
--
https://donmontalvo.com

Josh_Smith
Contributor III

Try this one:

$ prlsrvctl info --license | grep "serial" | awk '{ print $1 }' | cut -f2 -d'='

This tells cut to use '=' as a delimiter. Everything before '=' is field 1 (serial), everything after is field 2 (desired output). Specifying -f2 tells cut we just want field 2.

mm2270
Legendary Contributor III

I don't have Parallels to test, but this may also work:

prlsrvctl info --license | awk -F'"' '/serial/{print $2}'

Explanation:
Pull the data from prlsrvctl info passing to | awk, set up awk's field separator -F to be a quote mark '"', use awk's regex matching to only look at lines including "serial" in them '/serial/ and print field 2 {print $2}' (which happens to be the string between the quote marks)

donmontalvo
Esteemed Contributor III

Wow you guys rock, I'll get this into an EA and will punt this over to the EA here on JAMF Nation section with full credit to you guys.

#!/bin/sh
if [ -f "/usr/local/bin/prlsrvctl" ]; then
    echo "<result>`/usr/local/bin/prlsrvctl info --license | awk -F '"' '/serial/{print $2}'`</result>"
else
    echo "<result>"NotInstalled"</result>"
fi
--
https://donmontalvo.com

donmontalvo
Esteemed Contributor III

Craig Peterson (Parallels) gave us a couple more tips, will send them in for EA approval:

is_volume= returns yes for PDB or no for consumer (requires 10.1.2 or later for this to work):

prlsrvctl info --license | awk -F'"' '/is_volume/{print $2}'
--
https://donmontalvo.com

donmontalvo
Esteemed Contributor III

One other tip from Craig (Parallels)...

Parallels Desktop older than 10.1.1 or older will show key_number which would follow a PDEI.xxxxxxxx.00xx format.

Parallels Desktop 10.1.2 or later won't include a key_number value.

Is there a way to do the if statement in a way that if key_number returns no value, echo NoValue. If key_value returns a value, echo that value?

Here is the command:

/usr/local/bin/prlsrvctl info --license | awk -F '"' '/key_value/{print $2}'
--
https://donmontalvo.com

mm2270
Legendary Contributor III

@donmontalvo There are probably a few different ways you can approach this. The simplest way might be to check for a null value being returned by the command and then echoing back the appropriate string in the if/then section. For example:

#!/bin/sh

keyvalue=$(/usr/local/bin/prlsrvctl info --license 2>/dev/null | awk -F '"' '/key_value/{print $2}')

if [ -z "$keyvalue" ]; then
    echo "<result>No Value</result>"
else
    echo "<result>$keyvalue</result>"
fi

In the first command I'm piping errors to /dev/null 2>/dev/null I'm not certain if that's necessary since I don't have the /usr/local/bin/prlsrvctl binary on my Mac to check that with, but its a good idea in case you would normally get an error back or some string like "No value" etc. Since the if/then statement checks for a null value, we want to be sure nothing gets returned other than a valid key_value string.
Try that and see how it works. You'll need to test it on both 10.1.1 or older and 10.1.2 or newer versions to be sure.

donmontalvo
Esteemed Contributor III

@mm2270 nice, how does this look for returning $key_value if an old version (pre-10.1.2) is installed, or $serial if a new version (10.1.2 or later) is installed?

FYI, Only Parallels 10.1.2 or later is supported by their License Portal.

Mucho danke!

Don

#!/bin/sh

key_value=$(/usr/local/bin/prlsrvctl info --license 2>/dev/null | awk -F '"' '/key_value/{print $2}')
serial=$(/usr/local/bin/prlsrvctl info --license 2>/dev/null | awk -F '"' '/serial/{print $2}')

if [ -f "/usr/local/bin/prlsrvctl" ]; then
    if [ -z "$key_value" ]; then
        echo "<result>$serial</result>"
    else
        echo "<result>$key_value</result>"
    fi
else
    echo "<result>"NotInstalled"</result>"
fi
--
https://donmontalvo.com

donmontalvo
Esteemed Contributor III

@Josh.Smith thanks for the command, we tested and found it included the quotes, so we went with the other. Both work though. Going to JNUC2015?

--
https://donmontalvo.com

mm2270
Legendary Contributor III

Hi Don,
Looks OK from here, but again, I don't have the product here to test with. If it returns what you're after, then I'd say go for it.

CorpIT_eB
Contributor II

This is great!!

I am adding it to our EA list is there a way of extracting the Version that is installed?