d

WSH Get Fullname Property of a User Account

Read the fullname property of a user account. Other properties are read in a similar way.

/**
 *    Script:   getFullName.js
 *    Purpose:  Returns the Full Name property of a user account.
 *    Author:   Daren Thiel 
 *    Date:     25 Mar 2001 
 *    Web:      http://www.winscripter.com
 **/

// Print out the full name property for "someuser" account on "ComputerA"
WScript.Echo( getFullName( "ComputerA", "someuser" ) );

/** 
 * getFullName  - Returns the Full Name property for a user
 * 
 * example      - var fn = getFullName( "DOMAIN", "someuser" );
 *              - var fn = getLFullName( "DOMAIN/Computer", "someuser" );
 **/
 
function getFullName( domain, user )
{
    try
    {
        var m_user = GetObject( "WinNT://" + domain + "/" + user + ",user" );
        return( m_user.FullName );
    }
    catch( e )
    {
        return( "Error: " + e.description );
    }
}