Is there a way to specify a list of say 20 variables in a script and run the
same command for all variables without copying pasting the command 20 times
in a script? Below is an example of my current script - I'd really like to
simplify it to make future modifications much easier. It looks like there
are two options that may produce my desired end result - using an array
and/or using multiple instances of the same variable, for example: Group(1)
= group in domain1, Group(2) = group in domain2, etc.
Can anyone shed some light on how to cycle through many variables to the
same command?
Group01="cn=somegroup,ou=somou,dc=domain1,dc=com"
Group02="cn=somegroup,ou=somou,dc=domain2,dc=com"
(etc.)
Set objGroup = GetObject ("LDAP://"&Group01)
For each objMember in objGroup.Members
i = i + 1
AlertReportXX = i&". "&objMember.sAMAccountName&" (domain.com)"
objTextFile2.WriteLine(AlertReportXX)
EchoXX = "domain.com,,"&objMember.sAMAccountName
objTextFile.WriteLine(EchoXX)
Next
Set objGroup = GetObject ("LDAP://"&Group02)
For each objMember in objGroup.Members
i = i + 1
AlertReportXX = i&". "&objMember.sAMAccountName&" (domain.com)"
objTextFile2.WriteLine(AlertReportXX)
EchoXX = "domain.com,,"&objMember.sAMAccountName
objTextFile.WriteLine(EchoXX)
Next
(etc.)
wscript.echo i
wscript.quit