Getting the email of the currently logged user

Hi,

How do I get the email of the currently logged user?

Thanks.

1 Like

Hi,

If you want to get email address of the current user from ActivveDirectory, the following powershell script might help you.

CommandText property:

"$objADSystemInfo = New-Object -ComObject ""ADSystemInfo""; $dn = $objADSystemInfo.GetType().InvokeMember(""UserName"", ""GetProperty"", $Null, $objADSystemInfo, $Null); $objUser = [adsi]""LDAP://$dn""; Write-Output $objUser.Mail; Remove-Variable objUser; $ret = [System.Runtime.Interopservices.Marshal]::ReleaseComObject($objADSystemInfo)"

Main.xaml (5.2 KB)

Regards,

1 Like

Hi,

It worked! Thanks!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.