List User Accounts on a Computer or Domain
Example prints out the "Name" and "FullName" properties for each account
/**
* Script: listusers.js
* Purpose: Lists all users in a domains.
* Author: Daren Thiel
* Date: 06 Mar 2001
* Web: http://www.winscripter.com
**/
showusers( "PDC" );
/**
* showusers - prints list of user accounts and their full names
* for a given domain.
*
* example - showusers( "DOMAINNAME" );
* - showusers( "DOMAINNAME/Computer" );
**/
function showusers( domain )
{
try
{
var users = GetObject( "WinNT://" + domain );
var e = new Enumerator( users );
for( ; !e.atEnd(); e.moveNext() )
{
var user = e.item();
if( user.Class == "User" )
{
print( "User : " + user.Name );
print( "Full Name : " + user.FullName );
print( "============================" );
}
}
}
catch( e )
{
print( "Error: " + e.description );
}
}
function print( msg )
{
WScript.Echo( msg );
}