Ok Brian... I'm back. Fries are Ready
Here is some code that should do the trick with hopefully little modification. Change your RootDSE and your User Server and it should do the trick. Not sure what or how it affects email in AD. I did not do that kind of testing and I don't have the account authority to test Email deletion via this method.
***** Note: The MESSAGEBOX is all one line, only broken here for display.
*****
WARNING!! This is VERY DANGEROUS code... You could wipe out ALL the USERS AND DATA by using the wrong pathing. There would be no error checking and no way to UNDO the deletions. - USE/MODIFY AT YOUR OWN RISK!
code:
; DeleteUserAccounts.kix
; By NTDOC 07-23-2002
Break On
$nul = MESSAGEBOX("This script will DELETE ALL accounts in the specified OU and remove the Home Folder and ALL data... _
WARNING - WARNING This is an irreversible action. Click CANCEL to quit now, otherwise the removal of all accounts _
and data will continue...", "User Account Deletion", 273)
If $nul = 1
$Users = GetObject("LDAP://ou=Testing,ou=MyRegion,dc=MyDomain,dc=MyCompany,dc=com")
; You need to modify the $Users LDAP for your own AD path.
$Users.filter = "a","User"
For Each $member in $Users
$x = $member.SamAccountName
? "Removing account and home folder for "+$x
Shell '%COMSPEC% /C RD /S /Q "\\MyServer\USERS\$x"'
$Users.Delete ("User", $member.name)
? ''+@ERROR+' - '+@SERROR
Next
Endif
Please post an update when you can to let us know how it works out.
[ 23 July 2002, 23:23: Message edited by: NTDOC ]