JB4375
asked on
VBScript If INSTR Using A List of Values to Check
I'm running a report that lists all Active Directory Accounts and lists the following: User ID, Full Name, Description, Email Address, and Employee Type. The goal being to list all but service type accounts.
I've noticed some discrepancies where some accounts are listed as Generic, but they are actual user accounts. I can clean these up easily enough with another script, but my main concern is giving someone this report with everything already removed regardless of whether these discrepancies exist or not. The easiest way is skip files that have certain strings in the Description or User ID.
So if I use the following code:
If InStr(objUser.Description, "Workstation") Then objRecordSet.MoveNext
Is there a way to check for a list of strings, and most importantly, to see if a numeric value exists without a ridiculously long If, Then, Else If statement?
Thanks!!
I've noticed some discrepancies where some accounts are listed as Generic, but they are actual user accounts. I can clean these up easily enough with another script, but my main concern is giving someone this report with everything already removed regardless of whether these discrepancies exist or not. The easiest way is skip files that have certain strings in the Description or User ID.
So if I use the following code:
If InStr(objUser.Description,
Is there a way to check for a list of strings, and most importantly, to see if a numeric value exists without a ridiculously long If, Then, Else If statement?
Thanks!!
ASKER
OK...
Remarkably simple. Is there any limit to the number of items in the comma-delimited list?
Thanks again!!
Remarkably simple. Is there any limit to the number of items in the comma-delimited list?
Thanks again!!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Oh right. That makes more sense. So if the Description value was either of the following:
Workstation
Computer
Group
it would work. This does match the *entire* description though, so if the description were My Workstation, it would not find a match. This would probably work for the author.
Thanks for clarifying.
Rob.
Workstation
Computer
Group
it would work. This does match the *entire* description though, so if the description were My Workstation, it would not find a match. This would probably work for the author.
Thanks for clarifying.
Rob.
ASKER
Thanks guys!!
Rob I liked you approach because it seems easier to included a list of items, without dealing with all the syntaxt, AND it also deals with handling case. Something I hadn't even considered.
Rob I liked you approach because it seems easier to included a list of items, without dealing with all the syntaxt, AND it also deals with handling case. Something I hadn't even considered.
Sure, no problem. Thanks for the grade.
Regards,
Rob.
Regards,
Rob.
If InStr(1, ","&objUser.Description&",
' MoveNext
...