Home All Groups Group Topic Archive Search About

Delet NT4 and AD user accounts from text file



Author
12 May 2005 12:30 PM
numbatfouram
Hi
I have a list of about 75 user accounts that i need to delete from an NT4
domain, there will also be the same for my new 2003 AD domain as well. What i
need to do is i guess use ReaLine or something to read every line of the
input file and then action each user account based on the account name. It's
basically housekeeping for disabled users who have never been deleted!

Can someone please advise or supply an example of how i can do this, i would
appreciate any help!
Thanks lots
M

Author
12 May 2005 4:32 PM
Jerold Schulman
On Thu, 12 May 2005 05:30:15 -0700, numbatfouram <numbatfou***@discussions.microsoft.com> wrote:

>Hi
>I have a list of about 75 user accounts that i need to delete from an NT4
>domain, there will also be the same for my new 2003 AD domain as well. What i
>need to do is i guess use ReaLine or something to read every line of the
>input file and then action each user account based on the account name. It's
>basically housekeeping for disabled users who have never been deleted!
>
>Can someone please advise or supply an example of how i can do this, i would
>appreciate any help!
>Thanks lots
>M


Assuming you have simple SAMID names, one per line:

@echo off
if {%1}=={} @echo Syntax: CleanupDisabledAccounts FileName&goto :EOF
setlocal
if not exist %1 @echo CleanupDisabledAccounts - %1 not found.&endlocal&goto :EOF
set file=%1
for /f "Tokens=*" %%u in ('type %file%') do (
net user "%%u" /DELETE /DOMAIN
)
endlocal
Author
13 May 2005 2:22 PM
numbatfouram
Thanks a lot for that Jerold
Amazing what 9 lines of code can do as i think it would take so much more
effort to do this account deletion with scripts!

Currently deleting many user accounts from old NT4 domains (a lot more than
i thought originally). All i need to do is get my empty group list exported
and it's all good. I think i have a script for this but if you know of
anything off the top of your head it would be much appreciated!
Thanks again
M

Show quote
"Jerold Schulman" wrote:

> On Thu, 12 May 2005 05:30:15 -0700, numbatfouram <numbatfou***@discussions.microsoft.com> wrote:
>
> >Hi
> >I have a list of about 75 user accounts that i need to delete from an NT4
> >domain, there will also be the same for my new 2003 AD domain as well. What i
> >need to do is i guess use ReaLine or something to read every line of the
> >input file and then action each user account based on the account name. It's
> >basically housekeeping for disabled users who have never been deleted!
> >
> >Can someone please advise or supply an example of how i can do this, i would
> >appreciate any help!
> >Thanks lots
> >M
>
>
> Assuming you have simple SAMID names, one per line:
>
> @echo off
> if {%1}=={} @echo Syntax: CleanupDisabledAccounts FileName&goto :EOF
> setlocal
> if not exist %1 @echo CleanupDisabledAccounts - %1 not found.&endlocal&goto :EOF
> set file=%1
> for /f "Tokens=*" %%u in ('type %file%') do (
>  net user "%%u" /DELETE /DOMAIN
> )
> endlocal
>
>

AddThis Social Bookmark Button