OK, this is untested. I am basing it off of a working script, but had to change a lot because it had hard coded paths in it. You will need to verify the LDAP paths for your environment and adjust the script as needed.
This will read from an excel spreadsheet and add/remove groups as needed.
Put username in column A, Remove group in column B and the add group in column C.
set oExl = GetObject(,"Excel.Application")
r=1
Const LDOMAIN = "LDAP://AD-ENTIADM01/"
Const ENT_OU = ",DC=company,DC=local"
do until len(oExl.cells(r, 1).value) = 0
userName = oExl.cells(r, 1).value
removeGroup= oExl.cells(r, 2).value
addGroup= oExl.cells(r, 3).value
set objUser = GetUser2(userName)
addgpstr = LDOMAIN & addGroup & ENT_OU
delgpstr = LDOMAIN & removeGroup & ENT_OU
' bind to the groups
set addobjGroup = GetObject(addgpstr)
'now add the user to the group
objGroup.Add objUser.ADsPath
set delobjGroup = GetObject(delgpstr)
'now add the user to the group
objGroup.Remove objUser.ADsPath
r=r+1
loop
Public Function GetUser2(ByVal sAMAccountName)
Dim ADCon,ADCmd,ADRec,str
Set ADCon = CreateObject("ADODB.Connection")
Set ADCmd = CreateObject("ADODB.Command")
ADCon.Provider = "ADsDSOObject"
ADCon.Open "Active Directory Provider", UID, PWD
Set ADCmd.ActiveConnection = ADCon
ADCmd.Properties("Cache results") = False
ADCmd.Properties("TimeOut") = 120
str = "select sAMAccountName, ADsPath " & _
"from '" & LDOMAIN & "OU=users" & ENT_OU "' " & _
"where objectCategory='person' and sAMAccountName='" & sAMAccountName & "'"
ADCmd.CommandText = str
Set ADRec = ADCmd.Execute()
If ADRec.EOF Then
Set objUser = Nothing
Exit Function
End If
' Then bind to the IADs object.
Set GetUser2 = getObject(ADRec.Fields("adspath"))
End Function
I hope you find this post helpful. Please let me know if it was.
Regards,
Mark