Use SMO in SSMS

1

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?

    
asked by anonymous 18.05.2015 / 19:04

1 answer

1

Is it possible to use SQLDMO substitute SMO within SSMS (SQL Server 2008 R2 version)?

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.

Use functions like list instances within the network similar to% of SQLDMO%?

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
}

I removed this script from here .

    
18.05.2015 / 20:28