Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I need a full list of local users defined on a Windows Server 2003. It is not a part of an AD domain. I have found typing "NET USER" on the command line lists all users, but it does not include the Description or Full Name field, which I need. I can't find any command line option for it either.

It doesn't HAVE to be command line. The clue is I need to copy-paste the data into a processable format. The Computer Manager console is not a fan of copy pasting.

share|improve this question
add comment

1 Answer

Copy this into a .JS file.

var objWMIService = GetObject("winmgmts:\\\\.\\root\\cimv2");

var listLocalUsers = objWMIService.ExecQuery("SELECT * from Win32_UserAccount Where LocalAccount = True");

for(var enumLocalUser = new Enumerator(listLocalUsers); !enumLocalUser.atEnd(); enumLocalUser.moveNext()){
    var localUser = enumLocalUser.item();
    WScript.Echo("Short Name: " + localUser.Name);
    WScript.Echo("Full Name: " + localUser.FullName);
    WScript.Echo("Description: " + localUser.Description);
    WScript.Echo("\n");
}

VB example: On Error Resume Next Set objWMIService = GetObject("winmgmts:\.\root\cimv2") Set listLocalUsers = objWMIService.ExecQuery("Select * from Win32_UserAccount Where LocalAccount = True")

For Each localUser in listLocalUsers 
    Wscript.Echo "Short Name: " & localUser.Name 
    Wscript.Echo "Full Name: " & localUser.FullName 
    Wscript.Echo "Description: " & localUser.Description 
    Wscript.Echo "\n"
Next 

Then run it using cscript myGetLocalUsers.js or cscript myGetLocalUsers.vb at the command prompt.

Edit:

I haven't tested it so let me know if you get any errors.

share|improve this answer
    
The VB Script part worked, except I had to change objItem.Name to localuser.Name. Thanks very much! I also did some changes so that it's saved to file instead of displayed in message boxes. Final script here, for anyone interested: gist.github.com/1992686 –  Nilzor Mar 7 '12 at 11:48
    
Just for the record the JS script gave an error on line 1 char 1, but might be something I did wrong. Never mind though, solved the problem. –  Nilzor Mar 7 '12 at 11:52
    
The JS script works just fine for me. Glad that it worked out. –  surfasb Mar 7 '12 at 16:54
    
After running the script, the wmiprvse.exe network service process pegged itself to 99% CPU and had to be terminated. support.microsoft.com/kb/933593 Microsoft acknowledges this behavior and furnishes a hotfix. –  user308781 Mar 19 at 0:06
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.