PowerShell - Get All SQL Instances On Server

ben himself's picture

This script will return all SQL instances running on a server or list of servers.

cls
Import-Module -Name SQLPS -DisableNameChecking

$servers = "SERVER_NAME", "SERVER_NAME_2", "ETC";

foreach($server in $servers)
{
    $path = "SQLServer:\SQL\" + $server;
    $instances = Get-ChildItem -Path $path;
    $instances;
}

Tags: 

Categories: