Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Server > Scripting > Re: Disable users from Excel file

Reply
Thread Tools Display Modes

Re: Disable users from Excel file

 
 
Richard Mueller [MVP]
Guest
Posts: n/a

 
      10-19-2009


"primoz88" <> wrote in message
news...
>
> Hello Everyone,
>
> I have searched the forum ho to disable users' accounts in AD, but
> without success. I have an Excel file with one value set in column (Pre
> W2K Name). I would like to create the script to mass disable users'
> accounts in AD.
>
> Can you please help me out?
>
> Thanks a million
>
>
> --
> primoz88
> ------------------------------------------------------------------------
> primoz88's Profile: http://forums.techarena.in/members/143937.htm
> View this thread: http://forums.techarena.in/server-scripting/1260301.htm
>
> http://forums.techarena.in
>


A VBScript program would need to read the pre-Windows 2000 names from the
spreadsheet, use the NameTranslate object to convert to the Distinguished
Name, bind to each user object, then set the appropriate bit of the
userAccountControl attribute to disable the account (or use the
AccountDisabled property method of the user object). You can use an example
VBScript program on my web site to modify users in bulk from a spreadsheet
linked here:

http://www.rlmueller.net/UpdateUsers.htm

Since userAccountControl is not a single-valued string attribute, you must
use the program UpdateUsers2.vbs (download UpdateUsers2.txt and rename to
*.vbs). The first row of the spreadsheet must have the attribute names. Your
first column with pre-Windows 2000 names should have the header
"sAMAccountName". Add a second column with the heading "userAccountControl".
The value in the second column for each user to be disabled should be
"ADS_UF_ACCOUNTDISABLE". The program will read each row of the spreadsheet,
convert the sAMAccountName into the Distinguished Name, bind to the user
object, and set the appropriate bit of the userAccountControl attribute to
disable the account. The program assumes all users are in the domain you
authenticated to. The spreadsheet UpdateUsers4.xls linked on the page is an
example, except you only need two columns, the one headed "sAMAccountName"
and one headed "userAccountControl". The program writes a log to document
what happened. The name and path of the log file and the spreadsheet are
both hardcoded in the program, so you should modify these for your needs. I
hope this helps.

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How To Get Excel File Folder to Associate with Excel File Open ncprius Windows Vista File Management 2 04-07-2008 01:38 PM
Disable File Sharing for users with GPO Wilfried Windows Vista Networking 0 03-13-2008 04:01 PM
Excel File open in r/w by two users on network connectivity issue Jean-Paul Windows Server 1 01-09-2008 09:22 AM
Disable User accounts from excel çheek Scripting 3 08-01-2007 08:54 PM
How to create users using VBS from an Excel sheet. Lion Scripting 9 02-08-2006 11:08 PM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59