דרוש סקריפט:
אני מחפש סקריפט שיוציא לי את כל הdisplay name של המשתמשים של בactive directory לקובץ. המטרה היא סריקה מלאה של הactive directory, וכניסה לכל OU, (באופן דינאמי כלומר אם אני יוצר OU חדש אז אין צורך לשנות משהו בscript .) בכל אופן הנה הסקריפט הנוכחי המכיל הכנסת display name של משתמשים לקובץ אך מOU ספציפי :
אני מחפש סקריפט שיוציא לי את כל הdisplay name של המשתמשים של בactive directory לקובץ. המטרה היא סריקה מלאה של הactive directory, וכניסה לכל OU, (באופן דינאמי כלומר אם אני יוצר OU חדש אז אין צורך לשנות משהו בscript .) בכל אופן הנה הסקריפט הנוכחי המכיל הכנסת display name של משתמשים לקובץ אך מOU ספציפי :
'Global variables Dim oContainer Dim OutPutFile Dim FileSystem 'Initialize global variables Set FileSystem = WScript.CreateObject("Scripting.FileSystemObject") Set OutPutFile = FileSystem.CreateTextFile("test.txt", True) Set oContainer = GetObject("LDAP://OU=users,DC=test,DC=test") 'Enumerate Container EnumerateUsers oContainer 'Clean up OutPutFile.Close Set FileSystem = Nothing Set oContainer = Nothing WScript.Echo "Finished" WScript.Quit(0) Sub EnumerateUsers(oCont) Dim oUser For Each oUser In oCont Select Case LCase(oUser.Class) Case "user" If Not IsEmpty(oUser.distinguishedName) Then OutPutFile.WriteLine "dn: " & oUser.distinguishedName End If If Not IsEmpty(oUser.name) Then OutPutFile.WriteLine "name: " & oUser.Get ("name") End If 'need to do this because oUser.name would get back the Relative Distinguished name (i.e. CN=Jo Brown) If Not IsEmpty(oUser.st) Then OutPutFile.WriteLine "st: " & oUser.st End If If Not IsEmpty(oUser.streetAddress) Then OutPutFile.WriteLine "streetAddress: " & oUser.streetAddress End If Case "organizationalunit" , "container" EnumerateUsers oUser End Select OutPutFile.WriteLine Next End Sub