Listing Servers With A Particular Service Using PowerShell

Summary

How to Get List of Servers that have a particular Service installed using PowerShell

Body

 

Audience

Staff

Overview

How to Get List of Servers that have a particular Service installed using PowerShell.

 

Script to list Servers with a Particular View

 

To obtain a list of servers that have a specific installed software package the below PowerShell script will provide the results in a CSV format. Use the following scripts as a guide:

Reference points for running the script

  • The script requires a location of where to gather the list of servers from. This can be done by using a text file or an AD OU will work. What is shown below is the use of a text file.
  • The second part of the script is to identify the software package you are looking for. For instance if you are looking for A Software Package you would use the Service Name and NOT the service Description. Although there are many way to obtain the data this is the easiest way.
  • The last area for decision is the output file. In all the cases below using a CSV file for the export is the most applicable option.

Notes for an easier processing:

  • -ErrorAction SilentlyContinue = This allows the script to continue running if an error is encountered. If this entry is not in there the script may stall and NO notification would be apparent

Here is what a scripts looks like when obtaining a list of all software packages installed (the spaces between lines are not required, it is more for viewing). The key areas are the path to the server.txt file, The output file path and filename:

#Microsoft Defender Advanced Threat Protection Installed

$servers = Get-Content \\univ.pitt.edu\svc\NetAdmin\PowerShell_Files\servers.txt

$results= foreach( $server in $servers) {

write-host "Processing Server $Server"

Get-Service -Name "Sense" -ComputerName $server | Select-Object MachineName, Name, DisplayName, Status -ErrorAction SilentlyContinue

}

$results | Export-Csv -Path \\univ.pitt.edu\svc\NetAdmin\PowerShell_Files\MDATPservice.csv

 

 

 

Feedback and Concerns:

If you have any feedback regarding this article, please reach out to hsitkb@pitt.edu.  You can also leave a comment below as well. 

Details

Details

Article ID: 3832
Created
Tue 7/28/26 2:02 PM
Modified
Tue 7/28/26 2:02 PM