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.
objItem.Nametolocaluser.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: https://gist.github.com/1992686 – Nilzor Mar 07 '12 at 11:48wmiprvse.exenetwork service process pegged itself to 99% CPU and had to be terminated. http://support.microsoft.com/kb/933593 Microsoft acknowledges this behavior and furnishes a hotfix. – Mar 19 '14 at 00:06