如何从已加入域的机器通过UPN/用户名查询Active Directory用户邮箱
在已加入域的机器上通过UPN/用户名查询AD用户邮箱地址
以下是几种实用的查询方法,适用于已加入Active Directory域的Windows机器:
方法1:PowerShell(推荐)
需确保安装RSAT-AD-PowerShell模块(域控制器默认预装,成员机器可通过Install-WindowsFeature RSAT-AD-PowerShell安装)。
按用户主体名称(UPN)查询:
Get-ADUser -Filter "UserPrincipalName -eq 'john.doe@contoso.com'" -Properties EmailAddress | Select-Object Name, UserPrincipalName, EmailAddress若要批量匹配某域名下所有用户,可改用
-like:Get-ADUser -Filter "UserPrincipalName -like '*@contoso.com'" -Properties EmailAddress | Select-Object Name, UserPrincipalName, EmailAddress按用户名(sAMAccountName)查询:
Get-ADUser -Filter "sAMAccountName -eq 'jdoe'" -Properties EmailAddress | Select-Object Name, UserPrincipalName, EmailAddress
方法2:命令行工具(dsquery/dsget)
直接使用系统自带命令行工具,无需额外模块:
按UPN查询:
dsquery user -upn john.doe@contoso.com | dsget user -email按用户名查询:
dsquery user -samid jdoe | dsget user -email注:查询结果为空时,可能是用户未配置邮箱或参数输入错误。
方法3:图形化工具(AD用户和计算机)
适合不熟悉命令行的场景:
- 用
dsa.msc命令快速启动Active Directory用户和计算机 - 左侧导航栏选中目标域,点击顶部工具栏的「搜索」按钮
- 在搜索对话框中:
- 按UPN查询:选择「用户主体名称」字段,输入完整UPN
- 按用户名查询:选择「用户名」字段,输入目标用户名
- 找到用户后右键选择「属性」,在「常规」选项卡查看「电子邮件」字段
内容的提问来源于stack exchange,提问作者Sherwin Dourado
相关产品推荐
相关产品推荐

