Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Using PowerShell, how can I get the currently logged on domain user's full name (not only its username) without the need of the ActiveDirectory module?

share|improve this question
up vote 18 down vote accepted
PS C:\temp> $dom = $env:userdomain
PS C:\temp> $usr = $env:username
PS C:\temp> ([adsi]"WinNT://$dom/$usr,user").fullname
John Doe

Some other (mostly) obscure properties also available. A few useful ones:

  • Homedrive UNC
  • Homedrive Letter
  • Description
  • Login script


[adsi]"WinNT://$dom/$usr,user" | select *
share|improve this answer
Good answer. Of course, this is querying AD... :) – Massimo Mar 17 '14 at 20:31
Do I need domain admin rights to run this command? Or can the domain user itself can run this command? – Jonathan Rioux Mar 17 '14 at 21:02
Any domain user can query AD for this kind of information. – Massimo Mar 20 '14 at 16:43
@Massimo Not any domain user can query AD for this kind of information. Users can be not granted (or denied) the "Read account restrictions" permission, and be unable to query any data from Active Directory – Ian Boyd Jun 16 '15 at 15:58

I like the accepted answer, but just because I wanted to try this out myself:

$user = whoami
Get-WMIObject Win32_UserAccount | where caption -eq $user | select FullName



or if you wish to not have the header info and just the result:

$user = whoami
Get-WMIObject Win32_UserAccount | where caption -eq $user | select FullName | ft -hide
share|improve this answer
I read this too quickly, it does query AD. I verbally retract my vote. – BigHomie Mar 17 '14 at 21:14
But doesn't require the AD PS modules – squillman Mar 17 '14 at 21:28
@squillman it doesn't, just giving Cleaner a hard time. – BigHomie Mar 17 '14 at 21:31
Gotcha. Sorry, must have been decaffeinated... – squillman Mar 18 '14 at 14:44

One liner using Powershell 3.0:

gwmi win32_useraccount | where {$_.caption -match $env:USERNAME} | select fullname | ft -HideTableHeaders
share|improve this answer

Based on your comment on Craig620's accepted answer,

Do I need domain admin rights to run this command? Or can the domain user itself can run this command?

It sounds like you're trying to avoid installing powershell modules on user workstations, yes, but also, no, you don't need to be a domain admin to look up your own name in AD. You can look up pretty much any information that appears in the GAL in Outlook, including full name, as a standard user.

You can also look up other people's full names as a standard user in AD (using Get-WmiObject Win32_userAccount, if you want to avoid the AD modules). Service accounts that query AD (well, prior to managed service accounts) are usually standard, unprivileged AD users.

share|improve this answer

Using -match is not a good choice because a $env:USERNAME of "ed" will match "fred" and "edith". Instead use -eq for an exact match and add in the domain if needed. I use a foreach loop at the end to strip off all leading an trailing whitespace as an alternative to "select fullname | ft -HideTableHeaders" which prints a leading and trailing newline.

gwmi win32_useraccount | where {$_.caption -eq $("domain\" + $env:USERNAME)} | foreach {$_.fullname}
share|improve this answer

If you don't want to use the Active Directory module, you can't; unless you want to go even deeper and perform an actual LDAP query against a domain controller.

Any user information other than the username is stored in Active Directory, and it has to be retrieved there.

share|improve this answer
But when I open the start menu, the full name of the user is shown here! I mean, it must be stored somewhere? – Jonathan Rioux Mar 17 '14 at 20:18
Yes, it's stored somewhere. It's stored in Active Directory. – Katherine Villyard Mar 17 '14 at 20:26
It is probably stored/cached in the registry as well, but I didn't find it easily and gave up. – mfinni Mar 17 '14 at 21:35
It's true that it's stored in AD but the [ADSI] interface has been around a lot longer than the AD modules, and really isn't all that complicated, like the accepted answer shows. – Hunter Eidson Mar 20 '14 at 15:11

If you've always got .Net 3.5 or higher (which you should with PowerShell v4.0 and higher):

Add-Type -AssemblyName System.DirectoryServices.AccountManagement;
$DisplayName = [System.DirectoryServices.AccountManagement.UserPrincipal]::Current.DisplayName;

That class provides very easy access to all the common LDAP properties, so you don't need to lookup twice (once with WinNT and again with LDAP) or use [ADSISearcher] to do an LDAP search if you want some extended properties that WinNT doesn't implement.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.