如何在PowerShell中获取登录用户的电子邮件 [英] How to obtain email of the logged in user in powershell
本文介绍了如何在PowerShell中获取登录用户的电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用 Vbscript ,我们得到当前用户的电子邮件 ID.就像下面几行一样简单.
Using Vbscript , we are getting current user email id. It is as simple as with following lines.
Option Explicit
Dim objUser, objADSysInfo
Set objADSysInfo = CreateObject("ADSystemInfo")
Set objUser = GetObject("LDAP://" & objADSysInfo.UserName)
WScript.Echo objUser.Mail
如何使用 powershell 实现相同的功能?
How to achieve the same using powershell?
推荐答案
PS> $searcher = [adsisearcher]"(samaccountname=$env:USERNAME)"
PS> $searcher.FindOne().Properties.mail
这篇关于如何在PowerShell中获取登录用户的电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文