Creating DCM CI using VBScript RRS feed

  • Question

  • Hi All I am trying to create DCM Items and i have create around 1000 Items.

    I had posted this before and i was told SDK would help, i tried to nderstand SDK and I found the script:

    Sub DCMImportBaselineOrCI(swbemServices,   _

    ' Set required variables.
    readFile = 1  'constant
    fileContents          =    ""
    initialReadSucceeded  =    ""
    triStateTrue = -1  ' This sets the file read to Unicode.

    ' Check if source xml file exists.
    set fileSytemObject = CreateObject("Scripting.FileSystemObject")
    If fileSytemObject.FileExists(pathToFile) Then
        set textFile = fileSytemObject.OpenTextFile(pathToFile, readFile, False, triStateTrue)   
        fileContents = textFile.ReadAll
        initialReadSucceeded = true
        set textFile = Nothing

        Wscript.Echo " "
        Wscript.Echo "Successfully read " & pathToFile
        initialReadSucceeded = false

        Wscript.Echo " "
        Wscript.Echo "File does not exist."
    End If
    set fileSytemObject = Nothing

    If initialReadSucceeded Then
        On Error Resume Next

            ' Create an instance of configuration item.
            set newCI = swbemServices.Get("SMS_ConfigurationItem").SpawnInstance_()     
            ' Copy specified file contents (XML) into SMS_ConfigurationItem property.
            newCI.SDMPackageXML = fileContents
            ' Save configuration item.
            If Err.Number<>0 Then
                Wscript.Echo "Couldn't create configuration item."
                Wscript.Echo "Possible duplicate configuration item or invalid XML."
            End If
        On Error Goto 0
        Wscript.Echo " "
        Wscript.Echo "Failed to create configuration item."  
    End If 

    End Sub

    but when i give the XML file which i had taken from SCCM using view XML Definition but it does not like that.

    it gives the error that either it already exist or XML is not valid.

    could anyone please let me know what should be the format of xml. How i would be able to insert the name of the file, location of the file, SHA1 Hash value to that XML and use this script to create a new CI.


    Thanks in advance.

    Wednesday, January 18, 2012 11:54 AM