Service Versions Challenges

I have been tasked with writing an analysis with the following information for some of our “Tools”

If the service exists
Version of the Service

I am using this in each analysis property, in most cases…

IF (exists service whose (service name of it as string as lowercase = "servicename")) THEN (state of it & " - " & version of it as string) of service whose (service name of it as string as lowercase = "servicename") ELSE "Not Installed"

This works perfect in most cases. Then some not mentioned vendor failed to put the version number in the service application. This generates the “Singular expression refers to nonexistent object” error. So for that vendor tool I just manually edited the relevance to say “Version Unavailable”.

The final challenge, some services have names that are different for each customer (We are an MSP). For example, the SNOW MID server service name is snc_mid_MSP_MidServer_ABC and the only piece of that name that exists on all customers is the snc_mid_. I can get the data if the service is running, even if it produces an error (Because there are more than one service name begining in snc_mid) but I can’t get the version number.

I got the data by using the “contains snc_mid” (Again, I manually entered the text “Version Unavailable”)

IF (exists service whose (service name of it as string as lowercase contains "snc_mid")) THEN (state of it & " - " & "Version Unavailable") of service whose (service name of it as string as lowercase contains "snc_mid") ELSE "Not Installed"

Two questions…

Is there a way I can use “if exists version then list it” instead of manually editing the relevance and only display the version if it exists?

Is there a way to pull the actual service name using the “contains” statement then getting the version of the service using the full name?

The simplest way is probably to pull a plural result (where 0 results are also ok)

q: (service names of it, states of it, versions of it) of services whose (service name of it starts with "BES")
A: BESClient, Running, 10.0.7.52

If you have to use your result format (because some other tool expects it that way) I think you should be able to use

q: if exists services whose (service name of it starts with "BES") then (service name of it & " - " &  state of it & " - "  & (version of it as string | "Version Unavailable")) of services whose (service name of it starts with "BES") else "Not Installed"
A: BESClient - Running - 10.0.7.52

The pipe operator I used there is a handy error-handler shortcut in case you expect a possible error -

(version of it as string | "Version Unavailable" )

If the expression on the left of the pipe has an error, the result on the right is substituted instead. Both sides of the pipe require the same type - so I had to cast the version as string so it matched the type of the “Version Unavailable” message.

2 Likes

Well am finally calling it a night but I will run with this tomorrow.

@JasonWalker As always, thanks for your help

1 Like

In the analysis is there a way to display each result in the result screen instead of “multiple results”

You’d need to concatenate the plural results into a single string, like

q: concatenation "; " of (service name of it & " - " &  state of it & " - "  & (version of it as string | "Version Unavailable")) of services whose (service name of it starts with "BES" or service name of it starts with "MS")

A: BESClient - Running - 10.0.7.52; MSDTC - Stopped - Version Unavailable; MSiSCSI - Stopped - Version Unavailable

Can I use a new line instead of a "; "
concatenation “%0d%0a” of

You could, but I don’t know whether newlines are going to show up the way you want in the Console.

Correct, it didn’t.
So much for an easy read in the console. It really does not matter much, the lady that writes our reports will separate it in SQL and display it all nice and pretty in our reports.

Again, thanks for all of your help

1 Like

Back to this again.

We have an analysis for a set of tools that works great for all but one of those tools. This one tool will not get the version even though the executable has a version.

Usual relevance…

IF (exists service whose (service name of it as string as lowercase = "zabbix agent 2")) THEN (state of it & " - " & (version of it as string | "Version Unavailable")) of service whose (service name of it as string as lowercase = "zabbix agent 2") ELSE "Not Installed"

Take the error handling out…

From the executable
image

image

I think the issue is the service has an argument in the path. I get the same issue when I run it on other services with arguments in the path.

Any thoughts?

Hi @D.Dean,

I also don’t get why the service, when versioning is there, does not provide version information, but I’m very sure it’s not because of the command parameters, as we have several services where command arguments are present and we are still able to capture the version details.

However, the following method can be used as a workaround. -

Q: IF (exists service whose (service name of it as string as lowercase = "zabbix agent 2")) THEN (state of it & " - " & (unique value of ((values "DisplayVersion" of keys whose (value "DisplayName" of it as string contains "Zabbix Agent") of keys "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (if x64 of operating system then (x32 registry; x64 registry) else registry)) as string))) of service whose (service name of it as string as lowercase = "zabbix agent 2" as lowercase) ELSE "Not Installed"
A: Running - 6.4.2.2400
T: 18.509 ms
1 Like

Thanks, that was the plan, pull it from the registry, but I was wondering why it didn’t pull it from the executable. :frowning:
Thanks for the help.