Login | |
|
 |
Re: Find the differences in two text files - 4/11/2005 8:28:48 AM
|
|
 |
|
| |
esnmb
Posts: 441
Score: 0
Joined: 1/11/2005
From: USA
Status: offline
|
Interesting. Is there somewhere that shows that? Anyway, here is my completed script. ======================================== ' ************************************************ ' * ' * Create text files from AD search then compare ' * them to create a CSV with the differences. ' * ' ************************************************ On Error Resume Next MsgBox "Another Message Box will alert you when the script is complete",,"INFORMATIONAL" Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFile = objFSO.CreateTextFile("c:\All.txt") Set objFile1 = objFSO.CreateTextFile("c:\Group.txt") Set objFile2 = objFSO.CreateTextFile("c:\Diff.csv") objFile2.WriteLine "Members not in Microsoft IP Printing" & vbCrLf Set objOU = GetObject _ ("LDAP://ou=Users,ou=All Users,dc=mlnusa,dc=com") ObjOU.Filter = Array("user") For Each objUser in objOU objFile.WriteLine objUser.CN arrMemberOf = objUser.GetEx("memberOf") For Each Group in arrMemberOf If InStr(Group, "CN=Microsoft IP Printing") Then objFile1.WriteLine objUser.CN End If Next Next objFile.Close objFile1.Close ' ******************************************* ' * ' * Filter out differences in the text files. ' * ' ******************************************* Const TextMode = 1 Set hash = CreateObject("Scripting.Dictionary") Set hash2 = CreateObject("Scripting.Dictionary") hash.CompareMode = TextMode hash1.CompareMode = TextMode file1 = "c:\All.txt" file2 = "c:\Group.txt" Set ts = objFSO.OpenTextFile(file1,1) Do Until ts.AtEndOfStream temp = ts.ReadLine hash.Item(temp) = 1 Loop ts.Close Set ts = objFSO.OpenTextFile(file2,1) Do Until ts.AtEndOfStream temp = ts.ReadLine If hash.Exists(temp) Then hash.Item(temp) = hash.Item(temp) + 1 Else hash.Item(temp) = 1 End If Loop ts.Close For Each key In hash.Keys If hash(key) = 1 Then hash2(key) = True End If Next For Each key In hash2.Keys objFile2.WriteLine Chr(34) & key & Chr(34) & "," Next objFile2.Close objFSO.DeleteFile("c:\All.txt") objFSO.DeleteFile("c:\Group.txt") MsgBox "The script has finished executing.",,"COMPLETE"
|
|
| |
|
|
|
|
|