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
How to achieve the same using powershell?
I'd be concerned that the given answer doesn't use the fully qualified name. Granted that won't be a problem in most cases, but the method I'm using is as follows: