Извлечение Instance Name для станций SQL Server, зарегистрированных в AD (сценарий VBScript)
Const ADS_SCOPE_SUBTREE = 2
Set objConnection = CreateObject(«ADODB.Connection»)
Set objCommand = CreateObject(«ADODB.Command»)
objConnection.Provider = «ADsDSOObject»
objConnection.Open «Active Directory Provider»
Set objCommand.ActiveConnection = objConnection
objCommand.CommandText = _
«Select displayName from ?LDAP://CN=Computers,DC=mydomain,DC=com? « _
& «where objectClass=?mS-SQL-SQLServer?»
objCommand.Properties(«Page Size») = 1000
objCommand.Properties(«Timeout») = 30
objCommand.Properties(«Searchscope») = ADS_SCOPE_SUBTREE
objCommand.Properties(«Cache Results») = False
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
Wscript.Echo «Computer Name: « & objRecordSet.Fields(«displayName»).Value
objRecordSet.MoveNext
Loop