VB Login Script that removes the user logging in from specific AD group

I am not a great coder, and am a bit under a time crunch. I am writing a login script that needs to, check if the user is part of a specific group, delete all network printers if they are, then remove that user from the group.

I have the first two parts working, but am not having an easy time removing the user form the group. I do understand the users will need the proper AD permissions, I am testing with a Domain administrator account now. I am attaching what I have so far:
      
Thanks,

login-script-test3.vbs
sattermcAsked:
Who is Participating?
 
Joseph MoodyBlogger and wearer of all hats.Commented:
Set objADSysInfo = CreateObject("ADSystemInfo")
Set objGroup = GetObject("LDAP://CN=GROUP NAME,OU=OU GROUP is in,DC=DOMAIN,DC=local")
objGroup.Remove("LDAP://" & objADSysInfo.ComputerName) 

Open in new window


Just adjust the above script to reflect the path/name to your group. Be sure to give self the ability to remove itself from the group.
0
 
sattermcAuthor Commented:
Appended it, and configured values, errors out with " The server is unwilling to process the request."

on the line:
objGroup.Remove("LDAP://" & objADSysInfo.ComputerName)

I do have the group, having self add/remove rights, as well as the user, in the groups permissions. .. Am I missing something else rigths wise ?

Thanks,
0
 
sattermcAuthor Commented:
nevermind.. .just needed to swap computername with username.. everything works great.. then thanks.
0
 
Joseph MoodyBlogger and wearer of all hats.Commented:
Great!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.