Hi,
I am attempting to write a script which retrieves a list of anyone in the local administrators group. Once I have that, I want to remove certain members/groups from that list and use what is left over. I have the following code which works fine, but I am wondering if there is a cleaner way to do this? Is it possible to nest Strreplace (or a similar function) in a single line of code?
Admins = wntMemberList('','Administrators', @LOCALGROUP,1,0)
Admins = StrReplace(Admins,'.\Administrator','')
Admins = StrReplace(Admins,'XYZ.com\PC Admins','')
Admins = StrReplace(Admins,'XYZ.com\Domain Admins','')
Thank you
A WIL function is an expression so you can use it anywhere in a statement the makes sense for the function's return type. So yes, you can nest away to your heart's content; provided you don't exceed maximum line length. However, code is easier to debug if you don't nest function calls so it is better to get the kinks out of a section of script before entering nesting nirvana.
What is the syntax to be used if I were to nest those strreplace commands into one statement?
Admins = wntMemberList('','Administrators', @LOCALGROUP,1,0),'.\Administrator','')
Admins = StrReplace(StrReplace(StrReplace(Admins,'XYZ.com\PC Admins',''),'.\Administrator',''),'XYZ.com\Domain Admins','')
Thank you for the example. That's exactly what I was looking for.
Probably obvious but most of the functions can be used in such a way, even with each other.
Jim