Set oAPI = CreateObject("MOM.ScriptAPI")
set oDiscoveryData = oAPI.CreateDiscoveryData(0, SourceId, ManagedEntityId)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''' Now Create the Relationship and fill in its property values'''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' First create the source of the relationship which is the TFSApplicationTier Class with the key TFSATComputerName
'Call TraceLogMessage("Create the SourceClass :TFSApplicationTier and fill in its Key property values")
set oSource = oDiscoveryData.CreateClassInstance("$MPElement[Name='TeamFoundationServer2008.TFSApplicationTier']$")
call oSource.AddProperty("$MPElement[Name='TeamFoundationServer2008.TFSApplicationTier']/TFSATComputerName$",tfsATComputerName)
call oSource.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", sFQDNSource )
'Call TraceLogMessage("TFSATComputerName=["&tfsATComputerName&"];sFQDNSource=["&sFQDNSource&"]")
''''######################### Version Control Database ###############
'Call TraceLogMessage("Now Create the TargetClass: SQLServer:Version Control Database and fill in its Key property values")
set oDB=oDiscoveryData.CreateClassInstance("$MPElement[Name='TeamFoundationServer2008.TFSDatabase']$")
call oDB.AddProperty ("$MPElement[Name='MicrosoftSQLServerLibrary!Microsoft.SQLServer.Database']/DatabaseName$", sVCDatabaseName )
call oDB.AddProperty ("$MPElement[Name='MicrosoftSQLServerLibrary!Microsoft.SQLServer.ServerRole']/InstanceName$","MSSQLSERVER" )
call oDB.AddProperty ("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", sFQDNTarget )
'Call TraceLogMessage("DatabaseName =["&sVCDatabaseName &"];sFQDNTarget =["&sFQDNTarget &"]")
' note that these are all required key properties of Microsoft.SQLServer.2005.Database
'Then you create your relationship instance
'Call TraceLogMessage("Now Create the VC Relationship Instance")
set oRelnShipVC= oDiscoveryData.CreateRelationshipInstance("$MPElement[Name='TeamFoundationServer2008.ATtoDBContainmentRelationship']$")
'Call TraceLogMessage("Now Add the VC Relationship Instance")
Call oDiscoveryData.AddInstance(oRelnShipVC)
''''######################### Work Item Tracking Database ###############
'Call TraceLogMessage("Now Create the TargetClass: SQLServer:WIT Database and fill in its Key property values")
set oDB2=oDiscoveryData.CreateClassInstance("$MPElement[Name='TeamFoundationServer2008.TFSDatabase']$")
call oDB2.AddProperty ("$MPElement[Name='MicrosoftSQLServerLibrary!Microsoft.SQLServer.Database']/DatabaseName$", sWITDatabaseName )
call oDB2.AddProperty ("$MPElement[Name='MicrosoftSQLServerLibrary!Microsoft.SQLServer.ServerRole']/InstanceName$","MSSQLSERVER" )
call oDB2.AddProperty ("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", sFQDNTarget )
'Call TraceLogMessage("DatabaseName =["&sWITDatabaseName &"];sFQDNTarget =["&sFQDNTarget &"]")
' note that these are all required key properties of Microsoft.SQLServer.2005.Database
'Then you create your relationship instance
'Call TraceLogMessage("Now Create the WIT Relationship Instance")
set oRelnShipWIT= oDiscoveryData.CreateRelationshipInstance("$MPElement[Name='TeamFoundationServer2008.ATtoDBContainmentRelationship']$")
'Call TraceLogMessage("Now Add the WIT Relationship Instance")
Call oDiscoveryData.AddInstance(oRelnShipWIT)
''''######################### TFS Integration Database (based on BGCOE) ###############
'Call TraceLogMessage("Now Create the TargetClass: SQLServer:WIT Database and fill in its Key property values")
set oDB3=oDiscoveryData.CreateClassInstance("$MPElement[Name='TeamFoundationServer2008.TFSDatabase']$")
call oDB3.AddProperty ("$MPElement[Name='MicrosoftSQLServerLibrary!Microsoft.SQLServer.Database']/DatabaseName$", sTFSIntegration )
call oDB3.AddProperty ("$MPElement[Name='MicrosoftSQLServerLibrary!Microsoft.SQLServer.ServerRole']/InstanceName$","MSSQLSERVER" )
call oDB3.AddProperty ("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", sFQDNTarget )
'Call TraceLogMessage("DatabaseName =["&sWITDatabaseName &"];sFQDNTarget =["&sFQDNTarget &"]")
' note that these are all required key properties of Microsoft.SQLServer.2005.Database
'Then you create your relationship instance
'Call TraceLogMessage("Now Create the WIT Relationship Instance")
set oRelnShipTfsIntegration= oDiscoveryData.CreateRelationshipInstance("$MPElement[Name='TeamFoundationServer2008.ATtoDBContainmentRelationship']$")
'Call TraceLogMessage("Now Add the WIT Relationship Instance")
Call oDiscoveryData.AddInstance(oRelnShipTfsIntegration)
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</Script></ScriptBody>
<TimeoutSeconds>300</TimeoutSeconds>
</DataSource>
</Discovery>