Discussion Locked

check for existance of user account

0 helpful
4 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I build my 2K network user accounts using a batch file generated from a data base that is constantly changing. Is there a way to check for the existance of a user account from the command line, and pipe the result to a text file? Or if I export the server user database to an Excell database, can I compare one to the other?

4 replies

by curlergirl

Assuming you are using Active Directory, you can export the user list directly from the AD Users and Computers console. Just right click on the Users container (or other container that holds the user name information you want to export), and click "Export List...". Chose the .csv format if you want to import it into Excel - this works pretty well. You can use macros to get rid of unnecessary info and format the list for comparison in any way you want.

Hope this helps!

by chucketn

I have over 1900 users on the server and wanted a fast way to load names from an excell sheet and determine if the account exists.

by djbrown62

Here are two methods using Net User

@echo off
rem Method_1 ======
net user %1
echo %errorlevel% > Res1.txt
goto Done

rem Method_2 ======
net user %1

if errorlevel 2 goto No_User
if errorlevel 0 goto Yes_user

echo unknown error
goto done

:no_user
echo user %1 not found > Res2.txt
goto done

:yes_user
echo user %1 found > Res2.txt
goto done

:done

This discussion is closed to new replies.