Trying if check if SQL is installed on my multiple windows servers

SQLDev 96 Reputation points
2023-10-06T05:51:56.11+00:00

I have about 200 windows servers. How can I check if SQL Server is installed on any of those servers? Thanks.

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
14,494 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Olaf Helper 46,551 Reputation points
    2023-10-06T06:08:40.0233333+00:00

    What for a script do you mean?

    You can use the tool MAP = "Microsoft Assessment and Planning" to create an inventory, also with SQL Server informations.

    See https://www.mssqltips.com/sqlservertip/7428/microsoft-assessment-and-planning-toolkit-inventory-sql-servers/

    0 comments No comments

  2. ZoeHui-MSFT 41,446 Reputation points
    2023-10-06T06:41:11.3433333+00:00

    Hi @SQLDev,

    Also check this thread to see if it is helpful.

    https://stackoverflow.com/questions/42278128/how-to-check-if-an-application-is-installed-on-multiple-server-powershell

    Regards,

    Zoe Hui


    If the answer is helpful, please click "Accept Answer" and upvote it.

    0 comments No comments

  3. SQLDev 96 Reputation points
    2023-10-06T17:50:46.2866667+00:00

    Thanks everyone! How can I export the output to a csv file please? I tried the below export-csv -append -path but I don't see the servername and instancename columns being written to the output. Any ideas please? Thanks.

    $SQLInstances = Import-Csv C:\server_test.csv |% { Invoke-Command -ComputerName $_.ServerName {
     (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server').InstalledInstances
     }
     }
        foreach ($sql in $SQLInstances) {
           [PSCustomObject]@{
               ServerName = $sql.PSComputerName
               InstanceName = $sql | Export-Csv -Append -Path C:\output.csv -NoTypeInformation
           }
       }
    

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.