Discovery Rule for TFS SQL Instance. While there could be several SQL instances only one SQL instance is uniquely associated with a TFS instance. This relationship is established separately and is manifested either in the Health Explorer or the Diagram View.
Set oAPI = CreateObject("MOM.ScriptAPI")
set oDiscoveryData = oAPI.CreateDiscoveryData(0, SourceId, ManagedEntityId)
'# Filter out SQLEXPRESS Instances
IF InStr(vInstanceName,"SQLEXPRESS")=0 THEN
set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='TeamFoundationServer2008.TFSDatabaseInstance']$")
call oInst.AddProperty("$MPElement[Name='MicrosoftSQLServerLibrary!Microsoft.SQLServer.ServerRole']/InstanceName$",vInstanceName)
call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$",vPrincipalName)
call oDiscoveryData.AddInstance(oInst)
ELSE
' Call TraceLogMessage("SQL EXPRESS Instance skipped")
END IF
Call oAPI.Return(oDiscoveryData)
'###### FUNCTION TRACELOGMESSAGE ################
Function TraceLogMessage(ByVal sMessage)
Dim lsEventInformation
WScript.Echo sMessage
' Retrieve the name of this (running) script
Dim FSO, ScriptFileName
Set FSO = CreateObject("Scripting.FileSystemObject")
ScriptFileName = FSO.GetFile(WScript.ScriptFullName).Name
Set FSO = Nothing
On Error Resume Next
Dim oAPITemp
Set oAPITemp = CreateObject("MOM.ScriptAPI")
lsEventInformation = 3
oAPITemp.LogScriptEvent ScriptFileName, 4000, lsEventInformation, sMessage
On Error Goto 0
End Function