I am trying to use a free download from Microsoft called GP Inventory
to collect minimal data about the computers within my Domain.
This of course is easy enough to do and saves rather nicely into an XML
document.
I'd like to be able to work with this information in a more managable
format (for me anyway) so I was hoping to import it into a SQL DB.
Anyway, so I went to MS Knowledge base and came up with the following tutorial on the BulkLoad method.
http://support.microsoft.com/kb/316005/en-us
Which I was able to duplicate using copy and paste. In looking at
the different parts of this process I felt as though doing the same
thing for my GPInventory output would be easy enough to do. (Evidently
Not).
Is there anyway someone can help an XML rookie figure out how to do this?
Here is a piece of my data, my scheme, and my script. As of right
now the script is throwing an error at me which says: Schema: Missing
Element Definition "ManagedObject"
XML
<ComputerList>
<Computer Name="ACCT-520" QueryState="Queried" Username="">
<ManagedObject Name="WMI: Operating System" Query="Select Caption from Win32_OperatingSystem">
<Attribute Name="Caption" Value="Microsoft Windows 2000 Professional" />
</ManagedObject>
</Computer>
<Computer Name="ACCT-627" QueryState="Queried" Username="">
<ManagedObject Name="WMI: Operating System" Query="Select Caption from Win32_OperatingSystem">
<Attribute Name="Caption" Value="Microsoft Windows XP Professional" />
</ManagedObject>
</Computer>
</ComputerList>
Schema
<?xml version="1.0" ?>
<Schema xmlns="urn:schemas-microsoft-com:xml-data"
xmlns:dt="urn:schemas-microsoft-com:xml:datatypes"
xmlns:sql="urn:schemas-microsoft-com:xml-sql" >
<ElementType name="Computer" dt:type="string" />
<ElementType name="Attribute" dt:type="string" />
<ElementType name="Computerlist" sql:is-constant="1">
<element type="ManagedObject" />
</ElementType>
<ElementType name="Customers" sql:relation="Customer">
<element type="Computer" sql:field="Computer" />
<element type="Attribute" sql:field="Attribute" />
</ElementType>
</Schema>
Script
set objBL = CreateObject("SQLXMLBulkLoad.SQLXMLBulkLoad")
objBL.ConnectionString = "provider=SQLOLEDB.1;data source=Intranet;database=MyDatabase;uid=Asset;pwd=fakepass"
objBL.ErrorLogFile = "c:\error.log"
objBL.Execute "c:\map4.xml", "c:\customers3.xml"
set objBL=Nothing
You need to map your xml into a relational database using sql:relation and sql:relationship annotations. If you haven't already designed a relational database, bulkload can generate one from your annotations.
Here is a good introductory:
http://msdn.microsoft.com/xml/default.aspx?pull=/library/en-us/dnsql90/html/exchsqlxml.asp
No comments:
Post a Comment