Posted On July 8, 2019

PowerShell: 1-Liner to Discover SQL Servers on the Network

kimconnect 0 comments
blog.KimConnect.com >> Database >> PowerShell: 1-Liner to Discover SQL Servers on the Network

Run this command on server with SQL CLI installed (this will only detect SQL servers that has the SQL Service Discovery enabled)

PS C:\Windows\system32> [System.Data.Sql.SqlDataSourceEnumerator]::Instance.GetDataSources()

ServerName InstanceName IsClustered Version
---------- ------------ ----------- -------
TESTSQL01 SQLEXPRESS No 14.0.1000.169
TESTSQL02 SQLEXPRESS No 12.0.2000.8
TESTSQL02 SQLEXPRESS01 No 14.0.1000.169
TESTSQL02 SWPDM No 12.0.4100.1

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

T-SQL: Ad-hoc Commands to Backup All Databases

-- turn on Windows cmd shell EXEC sp_configure 'show advanced options', 1; GO RECONFIGURE; GO…

PowerShell: Get SQL Job History

$computername='sql01' function getSqlJobHistory($sqlServerName){ try{ if(!(get-module SqlServer)){ Install-Module -Name SqlServer } Import-Module -Name SqlServer $sqlServerInstance=Get-SqlInstance -ServerInstance…

PowerShell: Get SQL Server Performance Counters

Version 2 # getSqlPerformanceCounter.ps1 # version 0.02 $computername='sql0003.kimconnect.com' function getSqlPerformanceCounter($server=$env:computername,$sampleInterval=10,$maxSamples=1){ $PerformanceCounterSampleSet=$result=@() $counters=@( '\Memory\Available MBytes', '\Memory\Pages/sec',…