|
Answer» Hi'
I have created a list trough ADFIND. The list is all accounts from active directory, witch are not disable and have the password NEVER expires set.
The file (all.txt) is formatted like this:
Code: [SELECT] user1 user2 user3
Some of the users is allright, so I have another file that contains all accounts that is approved. That file (approved.txt) is formatted like this: Code: [Select]user2 user5
Now I need one file. The file should be a result, that contains all accounts listen in all.txt but not LISTED in approved.txt.
I think i need a combination of FOR and FIND /V command, but I'm stuck.
I don't know if it can be done using FOR and FIND, but here is a VBScript file which may be of use. Paste the code below into a file with a .vbs extension and run it from the command prompt.
Code: [Select]Option Explicit Dim oFso, iCase, inFile, strFile1, strFile2, strContent, arAll, arApproved, strOut, i, J, outFile, strOutFile, iFlag
Const ForReading = 1 Const ForWriting = 2
Set oFso = CreateObject( "Scripting.FileSystemObject" )
'**************** MAKE CHANGES BELOW AS REQUIRED **************** ' If case sensitivity matters, change this to 1 iCase = 0
' Full path to the file containing all the users names strFile1 = "c:\all.txt"
' Full path to the file containing all the approved users names strFile2 = "c:\approved.txt"
' Full path to the file which will contain the users who are not on the approved list strOutFile = "c:\notapproved.txt" '**************** MAKE CHANGES ABOVE AS REQUIRED ****************
Set inFile = oFso.OpenTextFile( strFile1, ForReading ) strContent = inFile.ReadAll inFile.Close If iCase Then arAll = Split( strContent, vbCRLF ) Else arAll = Split( LCase( strContent ), vbCRLF ) End If
Set inFile = oFso.OpenTextFile( strFile2, ForReading ) strContent = inFile.ReadAll inFile.Close If iCase Then arApproved = Split( strContent, vbCRLF ) Else arApproved = Split( LCase( strContent ), vbCRLF ) End If
strOut = "" For i = 0 To UBound( arAll ) iFlag = 1 For j = 0 To UBound( arApproved ) If arAll( i ) = arApproved( j ) Then iFlag = 0 Exit For End If Next If iFlag Then strOut = strOut & arAll( i ) & vbCRLF End If Next
If strOut <> "" Then Set outFile = oFso.CreateTextFile( strOutFile, True ) outFile.Write( strOut ) outFile.Close End If THX!! That works
|