How to get list of servers running in network using PowerShell

As a DBA its your repsonsibility to get list of SQL Servers running in network and manage them. As infrastructure grows its getting tough to get list of SQL Servers running in network along with their versions
It easy in Powershell
Let see how to use it



Run this command

 [System.Data.Sql.SqlDataSourceEnumerator]::Instance.GetDataSources()





Here it gives list of all servers where SQL Server is  running

Now if want to filter this result
Lets see how to use it

$a = "MDVLAMISHS"
[System.Data.Sql.SqlDataSourceEnumerator]::Instance.GetDataSources() | ? { $_.servername -eq $a}


It will filter resuts as show below




No comments:

Post a Comment

Popular Posts