Option Explicit Dim adoCommand, adoConnection, strBase, strFilter, strAttributes Dim objRootDSE, strDNSDomain, strQuery, adoRecordset Dim strDN, objUser Const ADS_PROPERTY_CLEAR = 1 'Removes Manager '--------------- Set objUser = GetObject("LDAP://" & WScript.Arguments(0)) objUser.PutEx ADS_PROPERTY_CLEAR, "manager", 0 objUser.SetInfo 'Removes Direct reports '---------------------- ' Setup ADO objects. Set adoCommand = CreateObject("ADODB.Command") Set adoConnection = CreateObject("ADODB.Connection") adoConnection.Provider = "ADsDSOObject" adoConnection.Open "Active Directory Provider" Set adoCommand.ActiveConnection = adoConnection ' Search entire Active Directory domain. Set objRootDSE = GetObject("LDAP://RootDSE") strDNSDomain = objRootDSE.Get("defaultNamingContext") strBase = "" ' Filter on user objects that have a manager. strFilter = "(&(objectCategory=person)(objectClass=user)(manager=" & WScript.Arguments(0) & "))" ' Comma delimited list of attribute values to retrieve. strAttributes = "distinguishedName" ' Construct the LDAP syntax query. strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree" adoCommand.CommandText = strQuery adoCommand.Properties("Page Size") = 200 adoCommand.Properties("Timeout") = 30 adoCommand.Properties("Cache Results") = False ' Run the query. Set adoRecordset = adoCommand.Execute ' Enumerate the resulting recordset. Do Until adoRecordset.EOF ' Retrieve values. strDN = adoRecordset.Fields("distinguishedName").Value ' Bind to the user object. Set objUser = GetObject("LDAP://" & strDN) ' Clear the manager attribute. objUser.PutEx ADS_PROPERTY_CLEAR, "manager", 0 ' Save changes. objUser.SetInfo ' Move to the next record in the recordset. adoRecordset.MoveNext Loop ' Clean up. adoRecordset.Close adoConnection.Close