Oh - if you really want CSV, use adfind. It has the "-csv" switch.
Regards, Michael B. Smith Consultant and Exchange MVP http://TheEssentialExchange.com From: Michael B. Smith [mailto:[email protected]] Sent: Wednesday, September 21, 2011 3:29 PM To: NT System Admin Issues Subject: RE: IT: How to Tell Remotely what Service Pack (Office, and Windows) remote PC is running You don't need PowerShell to do the query. dsquery * domainroot -filter objectCategory=computer -attr Name Location OperatingSystem OperatingSystemServicePack Doing Excel is never easy. PowerShell would line-for-line match vbscript for the Excel code. Regards, Michael B. Smith Consultant and Exchange MVP http://TheEssentialExchange.com From: Webster [mailto:[email protected]]<mailto:[mailto:[email protected]]> Sent: Wednesday, September 21, 2011 3:10 PM To: NT System Admin Issues Subject: RE: IT: How to Tell Remotely what Service Pack (Office, and Windows) remote PC is running 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:[email protected]]<mailto:[mailto:[email protected]]> 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 [email protected]<mailto:[email protected]> with the body: unsubscribe ntsysadmin ~ 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 [email protected]<mailto:[email protected]> with the body: unsubscribe ntsysadmin ~ 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 [email protected] with the body: unsubscribe ntsysadmin
