Lösche einen alten Computer aus der Domäne:
'lösche den gesuchten Computer aus der Domäne compnr = "Nbnr1234" FindandDeleteanComputerinDomain compnr '------------------------------------------------------------------------- Sub FindandDeleteanComputerinDomain(computer) Set objRootDSE = GetObject("LDAP://RootDSE") ADDomain = objRootDSE.Get("defaultNamingContext") Set objrootdse = nothing Const ADS_SCOPE_SUBTREE = 2 Set objConnection = CreateObject("ADODB.Connection") Set objCommand = CreateObject("ADODB.Command") objConnection.Provider = "ADsDSOObject" objConnection.Open "Active Directory Provider" Set objCommand.ActiveConnection = objConnection objCommand.CommandText = "Select distinguishedName from 'LDAP://" & ADDomain & "' where objectClass='computer' AND name ='" & computer &"'" objCommand.Properties("Page Size") = 2000 objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE Set objRecordSet = objCommand.Execute objRecordSet.MoveFirst Do Until objRecordSet.EOF dn = objRecordSet.Fields("distinguishedName").Value set objComputer = GetObject("LDAP://" & dn) wscript.echo "lösche: LDAP://" & dn objComputer.DeleteObject (0) objRecordSet.MoveNext Loop End Sub '-------------------------------------------------------------------------