Get-ADUser -Identity doesn't support UPN or forest functionality?

Greg Corey 21 Reputation points
2020-11-25T23:06:33.277+00:00

I was very surprised to discover that the -Identity switch for "Get-ADUser" doesn't support UPN. It already supports GUID and SID in addition to DistinguishedName and sAMAccountName. Is there a plan to add support for UPN?

Also, is there really no way to do a forest search with Get-ADUser? Couldn't you add a -Forest flag or detect the correct domain in the forest based on the "DC=" elements of DN or the user SID sans RID (or the search base if specified)?

Something like this works -- but seems crazy. Am I missing something?
get-adforest | select -ExpandProperty Domains | % { Try { get-aduser -server $_ -identity "someuser" } catch {} }

Windows for business | Windows Client for IT Pros | Directory services | Active Directory
Windows for business | Windows Server | User experience | PowerShell
0 comments No comments
{count} votes

Accepted answer
  1. Rich Matheisen 47,901 Reputation points
    2020-11-26T03:04:03.95+00:00

    You can use a Global Catalog server to search the entire forest. Use the -Server parameter and add ":3268" (the GC port number) at the end of the server name.

    For example:

    Get-ADUser -Identity "someuser" -Server GCServerName:3268

    To use the UPN instead of using the -Identity parameter and being restricted to using a DN, GUID, SID, or sAMAccountName, use -Filter instead. The drawback to using -Filter is that if it fails to find a match it won't throw an exception so you have to check to see if there was anything returned instead of relying on "-ErrorAction Stop" and Try/Catch.


1 additional answer

Sort by: Most helpful
  1. Anonymous
    2020-11-26T01:29:00.45+00:00

    Hi @Greg Corey ,

    You can submit your feedback over here
    https://windowsserver.uservoice.com/forums/301869-powershell

    Best Regards,
    Ian

    ============================================

    If the Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.