Now for St. MBS to show us how to accomplish the same thing in PowerShell in 5 
lines or less. :)

Carl Webster
Consultant and Citrix Technology Professional
http://www.CarlWebster.com<http://www.carlwebster.com/>


From: Guyer, Don [mailto:don.gu...@fiserv.com]
Subject: RE: IT: How to Tell Remotely what Service Pack (Office, and Windows) 
remote PC is running

Script for O/S and SP. Just enter your domain info:

-----------------------------------------------------------

On Error GoTo 0
Const ADS_SCOPE_SUBTREE = 2

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADSDSOObject"
objConnection.Open "Active Directory Provider"

'your LDAP Query here
strLDAPQuery = "LDAP://DC=domain,DC=com"

'get the working path of the script
strScriptPath = replace(wscript.scriptfullname,wscript.scriptname,"")

'Create Excel workbook
   Set objXL = wscript.CreateObject("Excel.Application")
   objXL.Visible = True
   objXL.WorkBooks.Add

'Specify the file to write
outputFile = strScriptPath & "Computer Accounts.xls"

'tell what row to start writing retrieved data to
icount = 2

Set objCOmmand.ActiveConnection = objConnection

objCommand.CommandText = _
    "Select Name, Location, operatingSystem, operatingSystemServicePack from '" 
& strLDAPQuery &  "' Where objectClass='computer'"
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
Set objRecordSet = objCommand.Execute

objRecordSet.MoveFirst
   objXL.ActiveSheet.Range("A1:D1").ColumnWidth = 20
   ObjXL.ActiveSheet.Cells(1,1).Value = "Computer Name"
   ObjXL.ActiveSheet.Cells(1,2).Value = "Location"
   ObjXL.ActiveSheet.Cells(1,3).Value = "Operating System Version"
   ObjXL.ActiveSheet.Cells(1,4).Value = "Service Pack"
   objXL.Range("A1:E1").Select
   objXL.Selection.Font.Bold = True
   objXL.Selection.Interior.ColorIndex = 1
   objXL.Selection.Interior.Pattern = 1 'xlSolid
   objXL.Selection.Font.ColorIndex = 2


Do Until objRecordSet.EOF
        On Error GoTo 0
               'If 
InStr(LCase(objRecordSet.Fields("OperatingSystem").Value),"server") Then
                       ObjXL.ActiveSheet.Cells(icount,1).Value = 
objRecordSet.Fields("Name").Value
                ObjXL.ActiveSheet.Cells(icount,2).Value = 
objRecordSet.Fields("Location").Value
                                      ObjXL.ActiveSheet.Cells(icount,3).Value = 
objRecordSet.Fields("OperatingSystem").Value
                                      ObjXL.ActiveSheet.Cells(icount,4).Value = 
objRecordSet.Fields("operatingSystemServicePack").Value
                'End If
    icount = icount + 1

    objRecordSet.MoveNext
Loop

Set ObjXL = Nothing

~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to listmana...@lyris.sunbeltsoftware.com
with the body: unsubscribe ntsysadmin

Reply via email to