Pergunta do script do Active Directory

1

Temos o Active Directory com 100 usuários. Como posso usar um script para exportar somente os usuários que foram adicionados ontem?

    
por Cell-o 04.02.2011 / 10:48

2 respostas

2

O seguinte dsquery retornará objetos de usuário criados após 2011-02-04:

dsquery * domainroot -filter "(&(objectCategory=person)(whenCreated>=20110204000000.0Z))" -limit 0
    
por 04.02.2011 / 12:05
0

Eu tenho este vbscript que estou usando para exportar usuários do AD e suas propriedades para um csv:

Const ForAppending = 8
Const ADS_NAME_INITTYPE_GC = 3
Const ADS_NAME_TYPE_1779 = 1
Const ADS_NAME_TYPE_SID_OR_SID_HISTORY_NAME = 12

Set objOU = GetObject("LDAP://OU=users,DC=example,DC=com")

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile("D:\temp\AD_Users_Export.csv")

Call enummembers(objOU)


Sub enumMembers(objOU)
On Error Resume Next

For Each objMember In objOU  

If ObjMember.Class = "user" Then


If Not (isempty(ObjMember.CN)) Then
        Initials = ObjMember.CN
Else
        Initials = ""
End If

If Not (isempty(objMember.GivenName)) Then
        FirstName = objMember.GivenName
Else
        FirstName = ""
End If

If Not (isempty(objMember.sn)) Then
        Lastname = ObjMember.sn
Else
        LastName = ""
End If

If Not (isempty(objMember.mail)) Then
        Mail = ObjMember.mail
Else
        Mail = ""
End If

If Not (isempty(objMember.whenCreated)) Then
        whencreated = ObjMember.whenCreated
Else
        whencreated = ""
End If



set objFolder = nothing
set objFile = nothing

Set objTextFile = objFSO.OpenTextFile ("D:\temp\AD_Users_Export.csv", ForAppending, True)


strText1 = FirstName & "," & Lastname & "," & Initials & "," & Mail & "," & strSidDec & "," & whencreated

objTextFile.WriteLine(strText1) 
objTextFile.Close

End If

If objMember.Class = "organizationalUnit" or OBjMember.Class = "container" Then 
enumMembers (objMember) 
End If

Next

End Sub
    
por 04.02.2011 / 12:25