Is it possible to use SMO SQLDMO within SSMS (SQL Server 2008 R2 version)? Use functions like list instances within the network similar to ListAvailableSQlServers()
of SQLDMO?
Is it possible to use SMO SQLDMO within SSMS (SQL Server 2008 R2 version)? Use functions like list instances within the network similar to ListAvailableSQlServers()
of SQLDMO?
According to Technet, the SQLDMO feature was removed from SQL Server 2012 on . The SMO feature has been retained. However, you should use it either by Powershell or by some application written in Visual Studio. The SSMS function is another.
The idea is that all support that existed using SQLDMO was transferred to Powershell. ListAvailableSQlServers()
can be rewritten as:
$objDomain = New-Object System.DirectoryServices.DirectoryEntry
$objSearcher = New-Object System.DirectoryServices.DirectorySearcher
$objSearcher.SearchRoot = $objDomain
$objSearcher.Filter = ("computer")
$objSearcher.PropertiesToLoad.Add("name")
$Computers = $objSearcher.FindAll()
foreach ($machine_name in $Computers | sort computername )
{
$sql_servers = get-wmiobject -class win32_service -computer $machine_name
$sql_servers | where { $_.name -like 'MSSQL$' -or $_.name -eq 'MSSQLSERVER'} | select name
}