Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7813507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T04:53:32+00:00 2026-06-02T04:53:32+00:00

I have a user’s network login name. From PowerShell and WMI is it possible

  • 0

I have a user’s network login name. From PowerShell and WMI is it possible to get a valid email for that user? Note that the login name is different than the name in the email, so I can’t just combine the login name with the email domain.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T04:53:34+00:00Added an answer on June 2, 2026 at 4:53 am

    The simplest way is to useActive-Directory.

    As you are using PowerShell tag and not PowerShell V2.0 you can use ADSI.

    Clear-Host
    $dn = New-Object System.DirectoryServices.DirectoryEntry ("LDAP://WM2008R2ENT:389/dc=dom,dc=fr","jpb@dom.fr","Pwd")
    
    # Look for a user
    $user2Find = "user1"
    $Rech = new-object System.DirectoryServices.DirectorySearcher($dn)
    $rc = $Rech.filter = "((sAMAccountName=$user2Find))"
    $rc = $Rech.SearchScope = "subtree"
    $rc = $Rech.PropertiesToLoad.Add("mail");
    
    $theUser = $Rech.FindOne()
    if ($theUser -ne $null)
    {
      Write-Host $theUser.Properties["mail"]
    }
    

    You can also use userPrincipalName instead of sAMAccountName in the filter, for userPrincipalName you can use user@domain form.


    Using WMI : If you absolutly want to do it with WMI.

    $user2Find = "user1"
    $query = "SELECT * FROM ds_user where ds_sAMAccountName='$user2find'"
    $user = Get-WmiObject -Query $query -Namespace "root\Directory\LDAP"
    $user.DS_mail
    

    You can use the second solution localy on your server or from a computer inside the domain, but it’s a bit more complicated to authenticate to WMI from outside the domain.


    Using PowerShell 2.0

    Import-Module activedirectory
    $user2Find = "user1"
    $user = Get-ADUser $user2Find -Properties mail
    $user.mail
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have user submitted tags that can be any type of (valid) UTF-8 string.
i have user data from database that parse inside p element . if user
i have user data from database that parse inside p element . if user
Using Pymongo for this scenario. I have User that has email, first_name, last_name. I
Following scenario: I have user object: ... @Column(name = TITLE) private String title; @NotNull
I have user-extensions.js that contain the following code of snippet: Selenium.prototype.doTypeRepeated = function(locator, text)
I have User table in my DB. A user has the fields name, company_id
I have User to Cars 1-to-n. mappings: User : <set inverse=true name=cars table=CAR> <key>
I have user control (myUserControl.ascx). in that i am trying to append script tag
I have user subscriptions in my DB, and the SUBSCRIPTIONS table has UID (that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.