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:

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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 ?

sattermcAuthor Commented:
nevermind.. .just needed to swap computername with username.. everything works great.. then thanks.
Joseph MoodyBlogger and wearer of all hats.Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.