![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| Vista Home Premium 32bit | how to obtain all pc in LAN and write to txtfile hi guys, i want to get all pc in my land and write in my .txt file. using vbs |
My System Specs![]() |
| | #2 (permalink) |
| | Re: how to obtain all pc in LAN and write to txtfile "webb" <guest@xxxxxx-email.com> wrote in message news:458a725a42878d7da35962287018ae33@xxxxxx-gateway.com... Quote: > > hi guys, i want to get all pc in my land and write in my .txt file. > using vbs > > > -- > webb objects in the domain. You can run the script below at a command prompt and redirect the output to a text file: ================== Option Explicit Dim adoCommand, adoConnection, strBase, strFilter, strAttributes Dim objRootDSE, strDNSDomain, strQuery, adoRecordset, strComputer ' Setup ADO objects. Set adoCommand = CreateObject("ADODB.Command") Set adoConnection = CreateObject("ADODB.Connection") adoConnection.Provider = "ADsDSOObject" adoConnection.Open "Active Directory Provider" adoCommand.ActiveConnection = adoConnection ' Search entire Active Directory domain. Set objRootDSE = GetObject("LDAP://RootDSE") strDNSDomain = objRootDSE.Get("defaultNamingContext") strBase = "<LDAP://" & strDNSDomain & ">" ' Filter on computer objects. strFilter = "(objectCategory=computer)" ' Comma delimited list of attribute values to retrieve. strAttributes = "sAMAccountName" ' Construct the LDAP syntax query. strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree" adoCommand.CommandText = strQuery adoCommand.Properties("Page Size") = 100 adoCommand.Properties("Timeout") = 30 adoCommand.Properties("Cache Results") = False ' Run the query. Set adoRecordset = adoCommand.Execute ' Enumerate the resulting recordset. Do Until adoRecordset.EOF ' Retrieve values and display. strComputer = adoRecordset.Fields("sAMAccountName").Value ' Remove trailing "$" character. strComputer = Left(strComputer, Len(strComputer) - 1) Wscript.Echo strComputer ' Move to the next record in the recordset. adoRecordset.MoveNext Loop ' Clean up. adoRecordset.Close adoConnection.Close -- Richard Mueller MVP Directory Services Hilltop Lab - http://www.rlmueller.net -- |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| how to get powershell to write to event log or write a log file? | PowerShell | |||
| Write-Error doesn't write anyting | PowerShell | |||
| The disk is write-protected. Remove the write-protection or... | Vista General | |||
| newline in Write-Debug or Write-Verbose | PowerShell | |||
| Can't obtain IP | Vista General | |||