Computer Services Const ForAppending = 8 Set objFSO = CreateObject("Scripting.FileSystemObject") Set objLogFile = objFSO.OpenTextFile("C:\Get_ServiceAccountName.csv", _ ForAppending, True) objLogFile.Write _ ("System Name,Service State,Display Name,Account Name ") objLogFile.Writeline Const ADS_SCOPE_SUBTREE = 2 Set objConnection = CreateObject("ADODB.Connection") Set objCommand = CreateObject("ADODB.Command") objConnection.Provider = "ADsDSOObject" objConnection.Open "Active Directory Provider" Set objCOmmand.ActiveConnection = objConnection objCommand.CommandText = _ "Select Name, Location from 'LDAP://OU=MyServersOU,DC=myChildDomain,DC=myRootDomain,DC=com' " _ & "where objectClass='computer'" objCommand.Properties("Page Size") = 1000 objCommand.Properties("Timeout") = 30 objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE objCommand.Properties("Cache Results") = False Set objRecordSet = objCommand.Execute objRecordSet.MoveFirst Do Until objRecordSet.EOF ComputerName = objRecordSet.Fields("Name").Value Call DoEnum(ComputerName) objRecordSet.MoveNext Loop objLogFile.Close Sub DoEnum(ComputerName) On Error Resume Next strComputer = ComputerName Wscript.Echo strComputer Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colListOfServices = objWMIService.ExecQuery _ ("Select * from Win32_Service") For Each objService in colListOfServices If instr(UCASE(objService.StartName), UCASE("Local")) >0 Then Else Wscript.Echo objService.DisplayName & vbTab & objService.StartName objLogFile.Write(objService.SystemName) & "," objLogFile.Write(objService.State) & "," objLogFile.Write(objService.DisplayName) & "," objLogFile.Write(objService.StartName) & "," objLogFile.writeline End If Next End Sub