mstoten
Posts: 50
Score: 0 Joined: 9/2/2007 Status: offline
|
Thanks John that seems to work pretty good actually. I have modified it alittle, this is what I have: ' Setup some variables SMSServer = "ServerName" SMSUID = "" 'leave blank if pass-thru SMSPWD = "" SMSDB = "SMS_XXX" WSID = "WSCAddData2" OutputFile = "c:\WSCExport.txt" ' Setup stuff needed to write to text file Set oFSO = CreateObject("Scripting.FileSystemObject") Set oOutFile = oFSO.OpenTextFile(OutputFile, 2, True) ' Prompt for netbios name/serial number var = inputbox("Please enter a netbios name or a serial number...","Enter Netbios/Serial Number") ' Create a SQL query that uses the netbios name/serial number we just asked for SQLQuery = "SELECT distinct PurchaseDate00, LeaseDate00, WarrantyDate00 , Name0, b.MachineID from dbo.WSCAdditionalData_DATA a , dbo.Computer_System_DATA b where a.MachineID = b.MachineID and b.MachineID LIKE '" & var & "' or b.Name0 LIKE '" & var & "'" ' ADODB Connection to SMS. Pull list of discovered users. Set oConn = CreateObject("ADODB.Connection") oConn.Open "Driver={SQL Server};Server=" & SMSServer & ";UID=" & SMSUID & ";PWD=" & SMSPWD & ";DATABASE=" & SMSDB & ";WSID=" & WSID Set oRS = oConn.Execute(SQLQUERY, 3) ' Loop through records and write line-by-line Do While Not oRS.EOF strLine = oRS.Fields("PurchaseDate00") strLine1 = oRS.Fields("LeaseDate00") strLine2 = oRS.Fields("WarrantyDate00") strLine3 = oRS.Fields("Name0") strLine4 = oRS.Fields("MachineID") oOutFile.WriteLine strLine oOutFile.WriteLine strLine1 oOutFile.WriteLine strLine2 oOutFile.WriteLine strLine3 oOutFile.WriteLine strLine4 oRS.MoveNext Loop Msgbox("Done") I am having some trouble though, if the PC does not have an entry for Purchase, Lease or Warranty then I receive an error because it cannot retrieve the data 'NULL' from the database. Is there a way I could display a msgbox if one of these entries are NULL?
< Message edited by mstoten -- 6/19/2008 2:59:46 AM >
|