18
Feb/10
0

Get Service Pack Levels of Servers via Active Directory

Script that queries Active Directory to retrieve Service Pack Levels (In this example only from Windows Server 2003 Machines)
Modify the strContainer variable to your requirements.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 
On Error Resume Next
 
Const ADS_SCOPE_SUBTREE = 2
strContainer = "DC=yourdomain,DC=com"
 
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = ("ADsDSOObject")
objConnection.Open "Active Directory Provider"
objCommand.ActiveConnection = objConnection
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.Properties("Page Size") = 1000
objCommand.CommandText = _
  "SELECT CN, operatingSystem, operatingSystemVersion, operatingSystemServicePack FROM 'LDAP://" & strContainer & "' " _
   & "WHERE objectCategory='computer' AND operatingSystem = 'Windows Server 2003' "
Set objRecordSet = objCommand.Execute
objRecordSet.Sort = "CN"
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
  Wscript.Echo objRecordSet.Fields("CN").Value & "," & objRecordSet.Fields("operatingSystem").Value & "," & objRecordSet.Fields("operatingSystemVersion").Value & "," 
  & objRecordSet.Fields("operatingSystemServicePack").Value
  objRecordSet.MoveNext
Loop
Print This Post
(1 votes, average: 5.00 out of 5)
Loading ... Loading ...
245 views
Comments (0) Trackbacks (0)

No comments yet.

Leave a comment


No trackbacks yet.