|
server
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Delet NT4 and AD user accounts from text file
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 On Thu, 12 May 2005 05:30:15 -0700, numbatfouram <numbatfou***@discussions.microsoft.com> wrote:
>Hi Assuming you have simple SAMID names, one per line:>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 @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 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 > > |
|||||||||||||||||||||||