Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remove All Security Groups from All Users in an OU

Status
Not open for further replies.

damienenglish

Technical User
Mar 21, 2012
27
GB
Hello Everyone

I am a real beginner at VBS but I have come up with the following script:

Const ADS_UF_ACCOUNTDISABLE = 2

Set objOU = GetObject("LDAP://ou=blah,ou=blah,ou=blah,ou=Site,ou=mainOU,dc=domain,dc=NET")
For Each objUser In objOU
If objUser.class="user" then
objUser.AccountDisabled = True
objUser.SetInfo
objUser.Put "userAccountControl", intUAC OR ADS_UF_ACCOUNTDISABLE
objUser.SetInfo

End if
Next
Set objOU = Nothing

Set objColUsers = GetObject _
("LDAP://ou=blah,ou=blah,ou=blah,ou=Site,ou=mainOU,dc=domain,dc=NET")

For Each objUser In objColUsers
ObjUser.msExchHideFromAddressLists = True
objUser.SetInfo
Next

What I want to add next, is a method that will remove all Security Groups from all user accounts within my specific OU. I have found many examples of removing groups from a particular user, or a particular Group from all users, but I require it to remove all security groups from all users apart from the Primary User Group.

Anyone have any suggestions or can this not be done?

Many Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top