Page 1 of 1 1
Topic Options
#61604 - 2001-12-21 04:17 AM Change LOGON.BAT in User Manger via ADSI script
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
This code was written and provided by Bryce (member# 600)
Thanks Bryce...

The following code is used to check and set the LOGON script batch file for
all the accounts in User Manager. You can use the substr lines to
exclude certain accounts.
Example: New users have been added by the Helpdesk and or an Analyst
and they did not set the users account to use the LOGON.BAT file.
This script will check and change that for all Domain Accounts.


The lines for logging can be moved around or removed depending
on what kind of logging you may want or not want.

The code below will exclude all accounts starting with the following:
$ # SMS

If you want to add more exclusions you should probably implement a SELECT statement.


NOTE This code requires:
Run from a Windows 2000 system or NT 4.0 with ADSI installed and
KiXtart 2001 4.01 (Copyright Ruud van Velsen 2001)
KiXtart 32 bits v2001 Release 4.01 (build 64) KiX2001_401.zip (491 kB Zip file)
http://kixtart.org/bin/KiX2001_401.zip

code:

$target = @domain
$target = getobject("WinNT://$target")
$loginscript = "LOGON.BAT"
if @error <> 0
exit(1)
endif
for each $user in $target
if $user.class = "USER"
if $user.loginscript <> "$loginscript" AND substr($user.name,1,1) <> "$$" AND substr($user.name,1,1) <> "#" AND substr($user.name,1,3) <> "SMS"
shell '%comspec% /c echo "' + $user.name + ' ' + $user.loginscript + '" >>c:\temp\beforelogons.txt'
$user.put("loginscript",$loginscript)
$user.setinfo
if $user.loginscript <> "$loginscript"
shell '%comspec% /c echo "' + $user.name + ' ' + $user.loginscript + '" >>c:\temp\afterlogons.txt'
endif
endif
next

Thanks again Bryce... Now I can keep some of my rougue analysts in line

[ 21 December 2001: Message edited by: NTDOC ]

Top
#61605 - 2001-12-21 04:40 AM Re: Change LOGON.BAT in User Manger via ADSI script
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Eh DOC,
Looks like it could be useful in AD. In NT4's UsrMgr, you can select a whole bunch of users and do a group modify on them. I haven't figured out a way to do that in AD.

Looking over the code, I'm counting one less ENDIF than IFs. It seems the deepest nested IF is missing an ENDIF. Can you verify the code to see if anything else is missing?

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#61606 - 2001-12-21 04:57 AM Re: Change LOGON.BAT in User Manger via ADSI script
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Hold on... Have you ever tried to modify 7,000+ accounts through the GUI ? Give it a try some time. About 30 minutes later when it comes back... You should be done.

This ADSI script runs through in about 1 minute. Oh, and try to scroll through 7,000+ accounts and pick out the ones you don't want to change. I think you will agree that this script is 100% faster and easier. This code can also probably be modified to change most other User Manager settings as well.

Yes, I did leave out an ENDIF I put in another line for logging. Then decided I did not really need it.

This should work ok.

code:

$target = @domain
$target = getobject("WinNT://$target")
$loginscript = "LOGON.BAT"
if @error <> 0
exit(1)
endif
for each $user in $target
if $user.class = "USER"
if $user.loginscript <> "$loginscript" AND substr($user.name,1,1) <> "$$" AND substr($user.name,1,1) <> "#" AND substr($user.name,1,3) <> "SMS"
shell '%comspec% /c echo "' + $user.name + ' ' + $user.loginscript + '" >>c:\temp\beforelogons.txt'
$user.put("loginscript",$loginscript)
$user.setinfo
if $user.loginscript <> "$loginscript"
shell '%comspec% /c echo "' + $user.name + ' ' + $user.loginscript + '" >>c:\temp\afterlogons.txt'
endif
endif
endif
next


Top
#61607 - 2001-12-21 05:45 AM Re: Change LOGON.BAT in User Manger via ADSI script
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Slow down DOC before you give yourself a wedgee...

I wasn't suggesting for a second that this wasn't useful or preferential. I was just trying to draw an example between NT4 and Win2K AD. There are a lot of things that don't work the same in AD.

I'm not up to speed on AD and ADSI yet, but suspect this script would only work on an NT SAM. There are a lot more user properties in AD and it would be nice to be able to do group mods on them too.

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#61608 - 2001-12-21 05:54 AM Re: Change LOGON.BAT in User Manger via ADSI script
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
ROFLMAO
Top
#61609 - 2001-12-21 05:55 AM Re: Change LOGON.BAT in User Manger via ADSI script
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
What the **** What if I want a wedgee?

I'm not pissed... Its too hard to pee with a wedgee

AD what is that Another Dead idea stolen from Novell ?

Hope you don't loose all your hair on all this stuff. I'm alreay bald from just thinking about AD and I have not really got past a couple meetings on it so far.

Top
#61610 - 2001-12-21 05:59 AM Re: Change LOGON.BAT in User Manger via ADSI script
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
EH Shawn, I lost my decoder ring
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#61611 - 2001-12-21 06:02 AM Re: Change LOGON.BAT in User Manger via ADSI script
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Rolling On Floor Laughing My Ass Off
Top
#61612 - 2001-12-21 06:05 AM Re: Change LOGON.BAT in User Manger via ADSI script
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
I think that was one of the best lines i've heard on this board ...
Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 708 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.047 seconds in which 0.018 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org