Login | |
|
 |
Grabbing website data and inserting into DB - 1/23/2007 1:52:54 AM
|
|
 |
|
| |
twilliamsen
Posts: 208
Score: 0
Joined: 1/18/2007
Status: offline
|
I had a previous script on here that grabs computer information from Active Directory and inserts it into an Access DB. Now my boss wants Warranty information from Dell's website to be done automatically as well. I found a script that would pull the information, but how do I get it into the DB? Here is the script I found.... I would use the code tags, but they suck and hard to read '=============================================================================== '= Pull the service tag from the bios '=============================================================================== strComputer = " . " Set objWMIService = getObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colBIOS = objWMIService.ExecQuery ("Select * from Win32_SystemEnclosure") For Each objBIOS in colBIOS 'Wscript.Echo "Serial Number of " & strComputer &;_ ' " is : " & objBIOS.SerialNumber strServiceTag = objBIOS.SerialNumber Next '=============================================================================== '= Create Internet Explorer Object '=============================================================================== Set Explorer = WScript.createObject("InternetExplorer.Application", "IE_") Do While (Explorer.Busy): Wscript.Sleep 250: loop Explorer.ToolBar = 0 ' hidden 'Explorer.ToolBar = 0 ' visible Explorer.StatusBar = 1 ' visible Explorer.Width = 800: Explorer.Height = 600 'Explorer.Left = 100: Explorer.Top = 50 Explorer.left = 225: Explorer.Top = 0 Explorer.Visible = 1 ' visible Explorer.Navigate "https://support.dell.com/support/topics/global.aspx/support/my_systems_info/en/details?c=us&cs=555&l=en&s=biz&amp~tab=2&ServiceTag="& strServiceTag Do While (Explorer.Busy): Wscript.Sleep 250: loop ============================================================== And I want to add it to this..... ============================================================= Const adOpenStatic = 3 Const adLockOptimistic = 3 Const adUseClient = 3 Set objConnection = CreateObject("ADODB.Connection") Set objRecordset = CreateObject("ADODB.Recordset") objConnection.Open "DSN=Inventory;" objRecordset.CursorLocation = adUseClient objRecordset.Open "SELECT * FROM Workstations" , objConnection, _ adOpenStatic, adLockOptimistic '================================================================================================ ' Retrieve Computer Account Names from Active Directory by Operating System Name '=============================================================================================== Const ADS_SCOPE_SUBTREE = 2 Set objConnectionAD = CreateObject("ADODB.Connection") Set objCommandAD = CreateObject("ADODB.Command") objConnectionAD.Provider = "ADsDSOObject" objConnectionAD.Open "Active Directory Provider" Set objCommandAD.ActiveConnection = objConnectionAD objCommandAD.CommandText = "Select Name from 'LDAP://DC=corp-nj,DC=mrsassociates,dc=com'" _ & "WHERE objectClass='Computer'" objCommandAD.Properties("Page Size") = 1000 objCommandAD.Properties("Searchscope") = ADS_SCOPE_SUBTREE Set objRecordSetAD = objCommandAD.Execute objRecordSetAD.MoveFirst Do Until objRecordSetAD.EOF GetPCInfo objRecordsetAD("Name") objRecordsetAD.MoveNext Loop Function GetPCInfo(strComputer) ' ================================================================================================== ' Grabs Computer Name, Manufacturer, Model, and Installed Ram from the ComputerSystem WMI Service '=================================================================================================== On Error Resume Next Set objWMIService = GetObject("winmgmts:\\" & strComputer& "\root\cimv2") If Err.Number <> 0 Then On Error GoTo 0 Exit Function End If On Error Goto 0 objRecordset.AddNew Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem") For Each objItem in colItems objRecordset("ComputerName") = objItem.Name objRecordset("Manufacturer") = objItem.Manufacturer objRecordset("Model") = objItem.Model objRecordset("Installed Ram") = objItem.TotalPhysicalMemory /1024 objRecordset("CPU Count") = objItem.NumberofProcessors Next ' ========================================================================= ' Queries the Processor WMI Service to grab the Processor Name ' ========================================================================= Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Processor") For Each objItem in ColItems objRecordset("CPU Name") = objItem.Name Next '================================================== ' Grabs Serial Number '================================================== Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_SystemEnclosure") For Each objItem in colItems objRecordset("Serial Number") = objItem.SerialNumber Next '==================================================================================================== ' Queries LogicalDisk WMI Service to retrieve Hard Drive Size and Free Space '==================================================================================================== Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_LogicalDisk") For Each objItem In ColItems objRecordset("Hard Drive Size") = objItem.Size objRecordset("Hard Drive Free Space") = objItem.FreeSpace Next '==================================================================================================== ' Queries the BIOS WMI Service to retrieve the BIOS Version '==================================================================================================== Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_BIOS") For Each objItem in colItems objRecordset("BIOS Version") = objItem.Name Next '========================================================================== ' Retrieve Operating System and Service Pack Version '========================================================================== Set colItems =objWMIService.ExecQuery("SELECT * FROM Win32_OperatingSystem") For Each objItem in colItems objRecordset("Operating System") =objItem.Caption objRecordset("Service Pack") = objItem.ServicePackMajorVersion & "." & _ objItem.ServicePackMinorVersion Next '===================================================================================================== ' Queries the PhysicalMemory WMI Service to retrieve the Memory Type '===================================================================================================== Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_PhysicalMemory") For Each objItem in ColItems objRecordset("RAM Speed") = objItem.Speed 'objRecordset("RAM Capacity") = objItem.Capacity pulls capacity of ram chip, not motherboard capacity Next Set ColItems = objWMIService.ExecQuery("SELECT * FROM Win32_PhysicalMemoryArray") For Each objItem In colItems objRecordSet("RAM Capacity") = objItem.MaxCapacity Next Dim strInvDateS Dim strInvTimeS strInvDateS = Date strInvTimeS = Time objRecordSet("Inventory Date") = strInvDateS objRecordSet("Inventory Time") = strInvTimeS ' ========================================================================================= ' Queries NetworkAdapterConfiguration WMI Service to get the IP Address ' Only if TCP/IP is running on target Computer ' ========================================================================================= Set IPConfigSet = objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled=TRUE") For Each IPConfig in IPConfigSet If Not IsNull(IPConfig.IPAddress) Then For i=LBound(IPConfig.IPAddress) to UBound(IPConfig.IPAddress) IPAddress = IPConfig.IPAddress(i) objRecordset("IP Address") = IPAddress objRecordset("MAC Address") = IPConfig.MACAddress Next End If Next objRecordset.Update '================================================================================= ' Closes Recordset and Connection '================================================================================= Set colItems = Nothing Set objWMIService = Nothing End Function
< Message edited by twilliamsen -- 1/23/2007 1:57:04 AM >
|
|
| |
|
|
|
 |
RE: Grabbing website data and inserting into DB - 1/23/2007 6:39:07 AM
|
|
 |
|
| |
ebgreen
Posts: 5246
Score: 31
Joined: 7/12/2005
Status: online
|
I would suggest reading the script that was provided and trying to understand how it works. Then make another function using the provided function as a guide to get the new piece of information.
_____________________________
"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
 |
RE: Grabbing website data and inserting into DB - 1/23/2007 7:21:24 AM
|
|
 |
|
| |
dm_4ever
Posts: 2721
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
|
The example I posted returns two dates since there are two End date on the page. You first need to get the latest date and then use that info however you want.
_____________________________
dm_4ever My philosophy: K.I.S.S - Keep It Simple Stupid Read Me: http://www.visualbasicscript.com/m_24727/tm.htm Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
|