StumpedTechy
MIS
Okay I have a dilema. We have a global distribution group we created for exchange emailing. The problem is from time to time people create an ID without remembering to put them into the group in question.
I was thinking to modify a script I collaborated on creating (someone from here helped out on that one as well) for a GAL dump to make it so that when the VBS is ran all of the users this script finds will be added to the correct global group. Can anyone help me out?
I was thinking instead of doing an outfile in each section I then add the users it parses out to to the distribution group. Would that be a simple as changing the outfile section to something like objGroup.Add ? -
Maybe put this at the beginning of the script - Set objGroup = GetObject("LDAP://yadda yadda")
then in each section do an objGroup.Add(objUser.AdsPath)
Is this too hard with the current script and possibly I should start over?
What we want is every user/contact in our AD system that has an email account listed in the e-mail field to be in this distribution group.
I was thinking to modify a script I collaborated on creating (someone from here helped out on that one as well) for a GAL dump to make it so that when the VBS is ran all of the users this script finds will be added to the correct global group. Can anyone help me out?
Code:
Dim rootDSE, domain
Set rootDSE = GetObject("LDAP://RootDSE")
Set domain = GetObject("LDAP://" & rootDSE.Get("defaultNamingContext"))
Set fso = CreateObject("Scripting.FileSystemObject")
Set outfile = fso.CreateTextFile("Gal Export.csv")
Call EnumUsers(domain.ADsPath)
Call EnumContacts(domain.ADsPath)
Call EnumOUs(domain.ADsPath)
Sub EnumOUs(adspath)
Dim container, ou
Set container = GetObject(adspath)
container.Filter = Array("OrganizationalUnit")
Call EnumUsers(container.ADsPath)
Call EnumContacts(container.ADsPath)
For Each ou In container
Call EnumOUs(ou.ADsPath)
Next
End Sub
Sub EnumUsers(adspath)
Dim container, user
Set container = GetObject(adspath)
container.Filter = Array("User")
For Each user In container
If user.Mail <> "" and user.sn <> "" and user.givenName <> "" Then
outfile.WriteLine user.sn & ", " & user.givenName & ", " & user.Mail
End If
Next
End Sub
Sub EnumContacts(adspath)
Dim container, contact
Set container = GetObject(adspath)
container.Filter = Array("Contact")
For Each contact In container
If contact.Mail <> "" and contact.sn <> "" and contact.givenName <> "" Then
outfile.WriteLine contact.sn & ", " & contact.givenName & ", " & contact.Mail
End If
Next
End Sub
I was thinking instead of doing an outfile in each section I then add the users it parses out to to the distribution group. Would that be a simple as changing the outfile section to something like objGroup.Add ? -
Maybe put this at the beginning of the script - Set objGroup = GetObject("LDAP://yadda yadda")
then in each section do an objGroup.Add(objUser.AdsPath)
Is this too hard with the current script and possibly I should start over?
What we want is every user/contact in our AD system that has an email account listed in the e-mail field to be in this distribution group.