Retrieves user account attributes found on the Account page of the user account object in Active Directory Users and Computers.
On Error Resume NextSet objUser = GetObject _("LDAP://cn=myerken,ou=management,dc=fabrikam,dc=com")objUser.GetInfostrUserPrincipalName = objUser.Get("userPrincipalName")strSAMAccountName = objUser.Get("sAMAccountName")strUserWorkstations = objUser.Get("userWorkstations")Set objDomain = GetObject("LDAP://dc=fabrikam,dc=com")objDomain.GetInfoEx Array("dc"), 0strDC = objDomain.Get("dc")WScript.echo "userPrincipalName: " & strUserPrincipalNameWScript.echo "sAMAccountName: " & strSAMAccountNameWScript.echo "UserWorkstations: " & strUserWorkstationsWScript.echo "dc: " & strDC
This is a VB Script, this can be used by saving the file in .vbs file