Massyn has asked for the wisdom of the Perl Monks concerning the following question:

#!/fellow/monks.pl

I'm writing a script that will change my password on about 5 different Windows NT/2000 systems. Unfortunatly, most of these do not have trusted domains or a similar setup.

The Windows command 'net user' only allows you to change the password on either the local machine, or the domain you're logged onto. I manage to call this command from ActiveState without a problem. My problem is now that I need to call the same command on a remote machine.

What I'm doing at the moment, is to issue an "net use \\$SERVER\ipc$ /user:$SERVER\$USERNAME $PASSWORD" against the box. That works. Now that I'm authenticated, I need to change the password.

I'd appreciate if any of the monks could provide me with a simple procedure I could use in my perl script, where I could specify the server name, username and new password.

Thanks!

#!/massyn.pl

You never know important a backup is until the day you need it.

Replies are listed 'Best First'.
Re: Changing NT passwords remotely?
by Marza (Vicar) on Nov 26, 2002 at 04:13 UTC

    You might take a look at Dave Roths Adminmisc module www.roth.net

    It has a nice little command that you can use:

    Win32::NetAdmin::UserChangePassword( ($machine | $domain),$user, $oldPassword, $newpassword)

    or better yet

    Win32::NetAdmin::SetPassword( ($machine | $domain),$user, $newpassword)

    The domains in question will have to grant you an access to do that. They can set up a global account and give you the authority. You can't side-step the security if you think about it. Microsoft has its problems but that would be a HUGE one if you could do that! ;-)