Reader to Reader - 14 Jan 2000
This month, two scripting solutions are provided: Debugging the IsLike Function and Obtain the Usernames of Group Members
January 14, 2000
[Editor's Note: Email your scripting solutions (400 words or less) to Reader to Reader at [email protected]. Please include your script and phone number. We edit submissions for style, grammar, and length. If we print your contribution, you receive $100.]
The sidebar "An Alternative for the Like Operator" in Dino Esposito, "Understanding VBScript: Operators," August 1999, introduces the user-defined IsLike function. This function matches strings against a given pattern. The IsLike function correctly returns True for
IsLike("command.com", "*.com")
However, the function incorrectly returns True for
IsLike("command.com", "*mand")IsLike("command.com", "*and*and*and*and")
Listing 1 contains the IsLike1 function, the debugged version of the IsLike function.
—Zhanbo Sun
[email protected]
Obtain the Usernames of Group Members
If you need to obtain a current list of members of a user-defined domain group, the script ParseGrp.pl can help. When you pass ParseGrp.pl the name of a domain group at the command line, the script generates a text file that lists the usernames of that group's members. To pass in the group's name, you use the command
parsegrp.pl "domain_group"
where domain_group is the domain group's name.
You can use the resulting text file, group.txt, as input to other batch files. For example, you can use the list of usernames as input for a utility that updates the user profiles of group members.
As Listing 2 shows, the script executes the Net Group command to obtain the list of usernames. (Listing 2 contains only an excerpt from ParseGrp.pl. You can find the complete script in the Code Library on the Win32 Scripting Journal Web site at http://www.win32scripting.com.) ParseGrp.pl then parses the results and places one username per line in group.txt. This script doesn't work with built-in groups (e.g., Administrators) or with group names that contain embedded spaces.
—Brian Guilfoyle
[email protected]
About the Author
You May Also Like