So I looked around for a script and found this on MS site for creating a user list with ldifde and a vbs script to clean it up.
http://support.microsoft.com/default.aspx/kb/555937
1. Write the batch file that runs LDIFDE against your Active Directory. Save the file as ExportDL.BAT using a text editor like Notepad. If you’re using Notepad, make sure that the file extension is .bat and not .bat.txt when you save the file.
@echo off
ldifde -f groups.ldf -d "cn=GroupName1,ou=myOU, dc=mydomain,dc=com" -l member -s mydc1
cscript modify.vbs //Nologo > "GroupName1.txt"
ldifde -f groups.ldf -d "cn=GroupName2,ou=myOU,dc=mydomain,dc=com" -l member -s mydc1
cscript modify.vbs //Nologo > "GroupName2.txt"
.
.
.
ldifde -f groups.ldf -d "cn=GroupNameN,ou=myOU,dc=mydomain,dc=com" -l member -s mydc1
cscript modify.vbs //Nologo > "GroupNameN.txt"
The function of each iteration in the batch file is to extract (using LDIFDE) each distribution group into an LDIF file named groups.ldf. The groups.ldf file is a temporary file. The next statement (cscript modify.vbs) invokes the modify.vbs script (described below). The modify.vbs script works on the groups.ldf file to produce meaningful output.
2. Write the MODIFY.VBS file. Again, you can use Notepad. You may not need to make any changes to the below code. This file opens the groups.ldf file created by LDIFDE in the batch file you created in step 1. It then extracts only the display names of each member of the group and places it into a new text file. The text file containing the group members is created automatically and is given the name of the distribution group from which the users were extracted. If the file already exists, it is overwritten automatically every time you run the script.
Dim objFileSystem, objInputFile
Dim strOutputFile, inputData, strData, strTemp
Const OPEN_FILE_FOR_READING = 1
' generate a filename base on the script name
strOutputFile = "groups.ldf"
Set objFileSystem = CreateObject("Scripting.fileSystemObject")
Set objInputFile = objFileSystem.OpenTextFile(strOutputFile, OPEN_FILE_FOR_READING)
' read everything in an array
inputData = Split(objInputFile.ReadAll, vbNewline)
For each strData In inputData
if Mid(strData, 1,2)="me" and len(strdata)>10 then
strTemp=Mid(strData, 12, InStr(1, strData,",",1)-12)
WScript.Echo strTemp
end if
if Mid(strData,1,2)=" C" then
strTemp=Mid(strData, 5, InStr(1, strData,",",1)-5)
WScript.Echo strTemp
end if
Next
objInputFile.Close
Set objFileSystem = Nothing
WScript.Quit(0)
The script worked great until the ldifde created a white space on one of the lines for a user this line had to be edited to correct the issue.
if Mid(strData,1,3)=" CN" then
Thanks to Jake Baker for helping me out with this.
I'm just a kiddie scripter so I appreciate the help bud.
No comments:
Post a Comment