Answered by:
I need more information on the AddProperty lines

Question
-
In the following script, Exactly what is the purpose of these two lines? It seems that the TargetComputer and o.File.name are being added to a table, but where and what table and what is the purpose of these additions? I know that I can remove the oFile.name addition from the script and everything still works, but not so with the TargetComputer line.
Call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", TargetComputer)
Call oInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", StripExtension(oFile.Name))Option Explicit
Dim oAPI
Set oAPI = CreateObject("MOM.ScriptAPI")
Dim oArgs
Set oArgs = WScript.Arguments
' Check for the required script arguments.
if oArgs.Count < 3 Then
' If the script is called without the required arguments,
' create an information event and then quit.
Call oAPI.LogScriptEvent("DiscoveryAppY.vbs",101,0, _
"script was called with fewer than three arguments and was not executed.")
Wscript.Quit -1
End If
Dim SourceID, ManagedEntityId, TargetComputer
SourceID = oArgs(0) ' The GUID of the discovery object that launched the script.
ManagedEntityId = oArgs(1) ' The GUID of the computer class targeted by the script.
TargetComputer = oArgs(2) ' The FQDN of the computer targeted by the script.
Dim oFso
Set oFso = CreateObject("Scripting.FileSystemObject")
Dim oDiscoveryData, oInst
Set oDiscoveryData = oAPI.CreateDiscoveryData(0, SourceId, ManagedEntityId)
If (oFso.FolderExists("C:\AppY")) Then
' Discovered the application. Create the application instance.
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Microsoft.Demo.Scripting.AppY']$")
' Define the property values for this instance. Available
' properties are determined by the Management Pack that
' defines the class.
Call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", TargetComputer)
Call oInst.AddProperty("$MPElement[Name='Microsoft.Demo.Scripting.AppY']/Version$", "2.0")
Call oInst.AddProperty("$MPElement[Name='Microsoft.Demo.Scripting.AppY']/InstallPath$", "C:\AppY")
Call oInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "Application Y")
Call oDiscoveryData.AddInstance(oInst)
' Discover the application's components.
Dim oFolder, oFile
Set oFolder = oFso.GetFolder("C:\AppY")
' Create a separate class instance for each file in the folder.
For each oFile in oFolder.Files
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Microsoft.Demo.Scripting.AppYComponent']$")
' Define the property values for this class instance. The
' available properties are determined by the
' Management Pack that defines the class.
Call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", TargetComputer)
Call oInst.AddProperty("$MPElement[Name='Microsoft.Demo.Scripting.AppYComponent']/ID$", StripExtension(oFile.Name))
Call oInst.AddProperty("$MPElement[Name='Microsoft.Demo.Scripting.AppYComponent']/FileName$", oFile.Name)
Call oInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", StripExtension(oFile.Name))
Call oDiscoveryData.AddInstance(oInst)Next
End If
' Submit the discovery data for processing.
Call oAPI.Return(oDiscoveryData)
' A helper function to remove the extension from a file name.
Function StripExtension (sFile)
StripExtension = Left(sFile, Len(sFile) -4)
End Function
Monday, November 9, 2009 3:30 PM
Answers
-
This line adds the parent classes key to the discovery package, which is what completes the hosting relationship. If you remove this, you get an error message in the ops manager log that says you are missing the key.
This line adds the hosting relationship key for the computer object.
Call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", TargetComputer)
This line just sets the display name of the discovered class. Since DisplayName property is declared at the System.Entity level in the inheritance tree, the system.entity reference sets the scope of the property value being set.
Call oInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", StripExtension(oFile.Name))
Microsoft Corporation- Marked as answer by Dan Rogers Monday, November 9, 2009 3:43 PM
Monday, November 9, 2009 3:43 PM
All replies
-
This line adds the parent classes key to the discovery package, which is what completes the hosting relationship. If you remove this, you get an error message in the ops manager log that says you are missing the key.
This line adds the hosting relationship key for the computer object.
Call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", TargetComputer)
This line just sets the display name of the discovered class. Since DisplayName property is declared at the System.Entity level in the inheritance tree, the system.entity reference sets the scope of the property value being set.
Call oInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", StripExtension(oFile.Name))
Microsoft Corporation- Marked as answer by Dan Rogers Monday, November 9, 2009 3:43 PM
Monday, November 9, 2009 3:43 PM -
Thanks for the quick response Dan.
So why is this set to 'Windows!Microsoft.Windows.Computer' for the AppY Discovery instead of 'Windows!Microsoft.Windows.LocalApplication' and for the AppY Component Windows!Microsoft.Windows.ApplicationComponent or even Microsoft.Demo.Scripting.AppY?
I really appreciate you taking the time to school me on this.
Monday, November 9, 2009 4:03 PM