Solved

Verify username and password Batch Script

Posted on 2010-09-23
4
829 Views
Last Modified: 2012-05-10
I am a domain Admin using a windows 2008 domain.  I have created the following batch script.



@echo off
Set /p Store=Enter the Account Name for a password reset:  

@echo You are going to attempt to change the password for %Store%'s Account.
Set /p Pass=Enter the new Password for %Store%'s Account:  
@echo off
net user %Store% %Pass% /DOMAIN



The problem is that I get no verification if the batch was successful.  I am hoping someone can help me out.  All I need is output that would verify if the username and new password work.

Thanks
0
Comment
Question by:mrfite
  • 2
4 Comments
 
LVL 5

Accepted Solution

by:
Eduardo Goicovich earned 250 total points
Comment Utility
check error level status after net function call, like this

net user %Store% %Pass% /DOMAIN

set el=%errorlevel%
if %el%==1 goto fail

exit /b 0

:fail
whetever you want
exit /b %el%
0
 
LVL 16

Expert Comment

by:Bryan Butler
Comment Utility
Check the $LASTEXITCODE and see what it is when successful.  Then check when fails just to make sure it's different.  Should be able to check this for success.
0
 
LVL 16

Expert Comment

by:Bryan Butler
Comment Utility
Ooops, that's with powershell.  belfegor has it for batch.
0
 
LVL 6

Expert Comment

by:dax_bad
Comment Utility
How about using a vbscript instead?

Here's a link about changing passwords for AD accounts
http://www.computerperformance.co.uk/vbscript/vbscript_setpassword.htm

Alternately change the script accept arguments

strContainer = wscript.arguments.item(0)                <--- could be a single user, or entire group of users
strPassword = wscript.arguments.item(1)

As long as you leave out "On error resume next" in whatever small script you create to set the password for a user, the windows scripting Host will throw an error if it cant find the user or set pw etc.

0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Companies that have implemented Microsoft’s Active Directory need to ensure that the Active Directory is configured and operating properly. If there are issues found and not resolved, it eventually leads the components to fail or stop working and fi…
Installing a printer using group policy preferences is not that hard let’s take a look at it. First lets open up your group policy console and edit the policy you want to add it to. I recommend creating a new policy for each printer makes it a l…
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now