GET-IT: TEAMS DAY | 1-Day Free Virtual Conference all about Teams. Here on Petri.com - 8/12/20 GET-IT: TEAMS DAY - 8/12/20

Output to a txt

Home Forums Scripting Windows Script Host Output to a txt

Viewing 1 post (of 1 total)
  • Author
    Posts
  • Avatar
    OKley
    Member
    #150618

    hi guys, i need to output to a txt file this vbs script

    Code:
    On Error Resume Next
    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.Properties(“Page Size”) = 1000
    objCommand.Properties(“Searchscope”) = ADS_SCOPE_SUBTREE

    objCommand.CommandText = _
    “SELECT ADsPath FROM ‘LDAP://dc=contoso,dc=com’ WHERE ” & _
    “objectCategory=’organizationalUnit'”

    Set objRecordSet = objCommand.Execute

    objRecordSet.MoveFirst

    Do Until objRecordSet.EOF
    Set objOU = GetObject(objRecordSet.Fields(“ADsPath”).Value)
    Wscript.Echo objOU.distinguishedName

    objOU.Filter = Array(“Computer”)

    For Each objItem in objOU
    Wscript.Echo ” ” & objItem.CN
    Next

    Wscript.Echo
    Wscript.Echo
    objRecordSet.MoveNext
    Loop

    thanks for your help

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.