You should also check how many SQL Server instances are installed on the server and their names for non-default instances. To do this, we can use SQL Management Objects (SMO) with PowerShell and then use the ServerInstances
member property:
#below should be a single line of code $managedComputer = New-Object "Microsoft.SqlServer.Management.Smo.Wmi.ManagedComputer" $servername #list SQL Server instances $managedComputer.ServerInstances | Select-Object Name, State, ServerProtocols, Urn | Format-List
The preceding script simply lists the instances installed. Note that MSSQLSERVER
is the name you'll see for a default instance: