powershell - 如何获取当前登录的AD用户的交换凭证?

标签 powershell active-directory exchange-server

我正在Powershell中编写脚本,以在域用户登录计算机后自动运行。脚本完成后,我希望它向我们的服务台票务系统发送电子邮件,为了知道脚本在哪个用户上运行,我想从用户的电子邮件中发送它。有没有一种方法可以通过当前登录用户的凭据来发送电子邮件。

我知道在第一次启动Outlook时,这些字段会自动用用户的电子邮件地址填充,因此我正在寻找类似的东西。

最佳答案

这是根据我在EWS脚本中使用的方法改编而成的:

$windowsIdentity = [System.Security.Principal.WindowsIdentity]::GetCurrent()
$sidbind = "LDAP://<SID=" + $windowsIdentity.user.Value.ToString() + '>'
$MailAddress = ([ADSI]$sidbind).mail.tostring()

$MailAddress 

假设您正在使用SMTP中继发送电子邮件。大多数Exchange组织将在某个地方为应用程序服务器和诸如MFD之类的无法设置为向域进行身份验证以向Exchange收件人发送电子邮件的事物的地方设置一个Exchange接收连接器。找出将其放在SMTPServerSend-MailMessage参数中的位置。

关于powershell - 如何获取当前登录的AD用户的交换凭证?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23144085/

相关文章:

powershell - 将参数从批处理文件传递给powershell脚本

powershell - 如何在 PowerShell ISE 中加载配置文件?

vb.net - 如何在 VB.Net 中运行 Powershell 脚本

sharepoint - 检查文件名的一个小问题(Powershell)

c# - 如何获取特定用户的所有 AD 组?

java - JRE 8u192 - javax.security.auth.login.FailedLoginException : Cannot bind to LDAP server

python-ldap add_s 无法为具有 OBJECT_CLASS_VIOLATION 的 AD 用户添加属性

exchange-server - 什么导致 OnSubscriptionError 在 EWS API 的 StreamingSubscriptionConnection 中被触发?

php - 使用 PHP mail() 函数通过 Exchange 发送电子邮件时出现延迟(使用 sendmail 作为中继)

powershell - 注册表 : Setting Child Permissions