Discussion:
Disable users from Excel file
(too old to reply)
primoz88
2009-10-19 16:23:18 UTC
Permalink
Hello Everyone,

I have searched the forum ho to disable users' accounts in AD, bu
without success. I have an Excel file with one value set in column (Pr
W2K Name). I would like to create the script to mass disable users
accounts in AD.

Can you please help me out?

Thanks a millio

--
primoz8
-----------------------------------------------------------------------
primoz88's Profile: http://forums.techarena.in/members/143937.ht
View this thread: http://forums.techarena.in/server-scripting/1260301.ht

http://forums.techarena.i
Richard Mueller [MVP]
2009-10-19 21:04:10 UTC
Permalink
Post by primoz88
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
--
primoz88
2009-10-20 11:23:53 UTC
Permalink
Thanks so much Richard!
You knowledge is huge and I really appreciate your effort.
I can always rely on you and guys in this forum to help me out, as am
really a new in scripting.

Thanks a lot once again

--
primoz8
-----------------------------------------------------------------------
primoz88's Profile: http://forums.techarena.in/members/143937.ht
View this thread: http://forums.techarena.in/server-scripting/1260301.ht

http://forums.techarena.i

Loading...