What's the proper method for detecting whether an arbitrary version of Apache Tomcat is installed on a given Windows server, which we can assume to be Windows Server 2012 R2 or greater, using PowerShell 5 or greater?
Asked
Active
Viewed 2,462 times
2
-
I self-answered, but I'm looking to see if there's a better way. There might not be. – HopelessN00b Jun 26 '18 at 21:21
1 Answers
2
What I've come up with so far is to use the Get-Service
cmdlet, along the lines of:
Get-Service | where-object {$_.name -like 'Tomcat?'}
This will return output like:
Status Name DisplayName
------ ---- -----------
Running Tomcat8 Apache Tomcat 8.5 Tomcat8
And that can be stored in a variable or sent to an if
statement to determine whether it's empty or not.
It might be worth wildcarding "Tomcat" within the filter, as this will presumably stop working with Tomcat 10, unless they decide to name it TomcatX.

HopelessN00b
- 53,795
- 33
- 135
- 209