» Site Navigation |
|
|
» Stats |
Members: 9,496
Threads: 11,750
Posts: 55,298
Top Poster: Nick (4,981)
|
| Welcome our newest member, JessicaD |
» March 2010 |
| S |
M |
T |
W |
T |
F |
S |
| 28 |
1
|
2
|
3
|
4
|
5
|
6
|
|
7
|
8
|
9
|
10
|
11
|
12
|
13
|
|
14
|
15
|
16
|
17
|
18
|
19
|
20
|
|
21
|
22
|
23
|
24
|
25
|
26
|
27
|
|
28
|
29
|
30
|
31
| 1 | 2 | 3 |
|
 |
03-12-2009, 05:11 PM
|
#1 (permalink)
|
Status: Junior Altiris Admin
Join Date: 02-26-2008
Location: Netherlands
Posts: 18
|
Query SQL eXpress database
I would like to, using a vbs script, query the SQL DS eXpress database and create a table with information like computername, ip address, mac address.
Is there someone sho can help me out on this ?
|
|
|
04-06-2009, 02:19 PM
|
#2 (permalink)
|
Status: Super Altiris Admin
Join Date: 03-08-2006
Location: Baltimore, MD
Age: 29
Posts: 576
|
This came out of the MSFT script center
Quote:
Const adOpenStatic = 3
Const adLockOptimistic = 3
Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")
objConnection.Open _
"Provider=SQLOLEDB;Data Source=MYExpressDBServer;" & _
"Trusted_Connection=Yes;Initial Catalog=express;" & _
"User ID=DOMAINNAME\USERNAME;Password=PASSWORD;"
objRecordSet.Open "SELECT * FROM Computer", _
objConnection, adOpenStatic, adLockOptimistic
objRecordSet.MoveFirst
Wscript.Echo objRecordSet.RecordCount
|
Anything particular you are looking for?
__________________
3rd Floor Garage Door Operator
|
|
|
04-07-2009, 02:53 AM
|
#3 (permalink)
|
Status: Junior Altiris Admin
Join Date: 02-26-2008
Location: Netherlands
Posts: 18
|
Thanks for the update. Maybe I can use that as well, but I found already something else.
See my script code below. This works perfect !
Quote:
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = wscript.createobject ("WScript.Shell")
MyServer="<sql_db_server_name>"
Set DBCon = CreateObject("ADODB.Connection")
DBCon.Open "Provider=SQLOLEDB;Server=" & MyServer & ";database=eXpress;Trusted_Connection=yes"
strHeader = "computername,groupname,serial,macaddress,ipaddres s,computertype,manufacturer,model,ostype,lastupdat e"
wscript.echo strHeader
objReportFile.WriteLine strHeader
SQL = "select comp.computer_name,grp.name,comp.serial_num,n.mac_ addr,netw.ip_address,comp.prod_name,comp.manuf,com p.model_num,comp.os,ses.last_update from dbo.computer comp inner join dbo.nics n ON comp.computer_id = n.computer_id inner join dbo.computer_display netw ON comp.computer_id = netw.computer_id inner join dbo.computer_group grp ON comp.group_id = grp.group_id left join dbo.sessions ses ON comp.computer_id = ses.computer_id order by comp.computer_name asc"
Set TargetGUID = DBCon.Execute(SQL)
Do While TargetGUID.EOF = False
MyGUID = TargetGUID.Fields("computer_name").Value & "," & TargetGUID.Fields("name").Value & "," & TargetGUID.Fields("serial_num").Value & "," & TargetGUID.Fields("mac_addr").Value & "," & trim(TargetGUID.Fields("ip_address").Value) & "," & TargetGUID.Fields("prod_name").Value & "," & TargetGUID.Fields("manuf").Value & "," & TargetGUID.Fields("model_num").Value & "," & TargetGUID.Fields("os").Value & "," & TargetGUID.Fields("last_update").Value
wscript.echo MyGUID
select case TargetGUID.Fields("model_num").Value
case "098Ch"
AmountT5710 = AmountT5710 + 1
case "0A24h"
AmountT5720 = AmountT5720 + 1
case Else
AmountTOther = AmountTOther + 1
end select
AmountTOT = AmountTOT + 1
TargetGUID.MoveNext
Loop
DBCon.Close
|
|
|
|
 |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|