Utlizar SMO in SSMS

Asked

Viewed 32 times

1

It is possible to use SMO substitute for the SQLDMO within the SSMS (SQL Server 2008 R2 version)? Use functions such as listing instances within the network similar to ListAvailableSQlServers() sqldmo?

1 answer

1

It is possible to use SMO as a substitute for SQLDMO within SSMS (SQL Server 2008 R2 version)?

According to Technet, the SQLDMO feature has been removed from SQL Server 2012 onwards. The SMO feature has been retained. However, you must use it either by Powershell or by some application written in Visual Studio. The SSMS function is another.

Use functions such as listing instances within the network similar to ListAvailableSQlServers() sqldmo?

The idea is that all existing support using SQLDMO is 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 took this script from here.

  • Thanks Gypsy, I will really have to make "some" kkkkkk changes. It had some very useful codes... but...... take a look at this one:

Browser other questions tagged

You are not signed in. Login or sign up in order to post.