Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ' UserDelete .vbs
- ' Sample VBScript to delete users in a named OU
- ' src : http://www.computerperformance.co.uk/ezine/ezine134.htm#Example_3_-_VBScript_to_Delete_All_Users_in_a_Named_OU.
- ' ------------------------------------------------------------'
- Option Explicit
- Dim objOU, objUser, objRootDSE
- Dim strContainer, strCN, strObject, strDNSDomain
- ' Bind to Active Directory Domain
- Set objRootDSE = GetObject("LDAP://RootDSE")
- strDNSDomain = objRootDSE.Get("DefaultNamingContext")
- strObject = "user"
- ' -------------------------------------------------------------'
- ' Important create OU=Contacts or change value for strContainer
- ' -------------------------------------------------------------'
- strContainer = "OU=direction,ou=montreal-ou,ou=educ-plusinc, "
- strContainer = strContainer & strDNSDomain
- set objOU =GetObject("LDAP://" & strContainer)
- For each objUser in objOU
- If objUser.class= strObject then
- ' The heart of this script - delete object
- strCN = "CN=" & objUser.cn
- objOU.delete strObject, strCN
- End if
- next
- set objOU = Nothing
- ' End of VBScript
Add Comment
Please, Sign In to add comment