Winscripter
  WSH
  Forums
  Downloads
  Books
  Links
  Amazon




Login
Register

© winscripter.com
1998-2004







List user accounts on a computer or domain

Posted by on Friday, January 16, 2004 (PST)

Example prints out the account name and full name of each account on a computer or domain.
/**
 *    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 );
}










Add Your Comment



WSH and ADSI Administrative Scripting

New Articles
  • List installed COM objects and associated ProgIDs
    Script: Lists all COM Objects and their associated ProgIDs (If available). Win32_ClassicCOMClassSetting

  • Script: File Rotator
    Script: Rotate files where the most current file has the lowest number in the archive. When files exceed the retention period, they are deleted. Typically used for log files, backups, etc..

  • Script: Create IIS Website and DNS record
    Script: Dan Casier sent me this script that will create a website and appropriate DNS record. The script is intended for Windows 2000 Server with local DNS and necessary DNS mof installed.


  • Winscripter   |  WSH   |  Forums   |  Downloads   |  Books   |  Links   |  Amazon