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 3,342 times
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
- 54,273