Get server hostnames on which MSSQLServer service is installed

With this simple script, you will be able to get the server names on which the MS SQL Server service is installed.

First, an array is built with the computer names and the following properties :

  • only the “Server” operating systems
  • only physical servers (virtual cluster nodes are excluded)
  • only enabled computer accounts

The cmdlet Get-service is used to query all the servers