【问题标题】:Powershell - Organizer Email AddressPowershell - 组织者电子邮件地址
【发布时间】:2019-08-04 03:00:18
【问题描述】:

我正在尝试使用 Powershell 在 MS Exchange 2010 中检索会议组织者的电子邮件地址。

(Get-Mailbox -Identity "John Doe").PrimarySmtpAddress

我收到以下错误

无法执行操作,因为在“xxxxxxxxxxxxxx”上找不到对象“John Doe”

这些都是刚刚创建的会议,组织者怎么可能不存在呢?

编辑:

这是事件的顺序:

  • 在特定日期范围内从交易所获取日历事件列表
  • 为每个活动获取组织者的电子邮件地址

完整脚本:

$credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $username,$password
$session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://xxxxxxxxxxxxxxx/PowerShell -Authentication kerberos -Credential $credential
Import-PSSession -Session $session -DisableNameChecking

#Date ranges
$exportDate = Get-Date -Format d
$startTime = (Get-Date).AddDays(-1) 
$endTime = (Get-Date).AddDays(+1)

$app = New-Object -ComObject Outlook.Application
$ns = $app.GetNamespace('MAPI')
$calFolder = 9
$calItems = $ns.GetDefaultFolder($calFolder).Items
$calItems.Sort("[Start]")
$calItems.IncludeRecurrences = $true
$dateRange = "[Start] >= '{0}' AND [End] <= '{1}'" -f $startTime.ToString("g"), $endTime.ToString("g")
$calExport = $calItems.Restrict($dateRange)

$exportFile = "D:\file.csv"
$calExport | select Subject, StartInStartTimeZone, EndInEndTimeZone, Duration, Organizer, RequiredAttendees, OptionalAttendees, Location | sort StartUTC -Descending | Export-Csv $exportFile
$exportData = Import-Csv $exportFile

foreach ($line in $exportData)
    {
        $emailAddress = $line.Organizer
        $emailAddress = (Get-Mailbox -Identity $line.Organizer).PrimarySmtpAddress
        $line | Add-Member -Membertype Noteproperty -Name OrganizerEmail -Value $emailAddress
        [array]$csvData += $line
        $emailAddress = $null
    }

Remove-PSSession $session

请帮忙!

【问题讨论】:

  • 因此,目标邮箱必须具有“John Doe”的名称、显示名称或别名的 AD 属性。情况似乎并非如此。你能用-Identitfy的samaccountname 或其他可接受的属性找到它吗?
  • 也许这只是我的概念上的误解 - 我已经编辑了上面的原始问题以澄清一些事情。请阅读以上内容
  • 我想你掌握了更多信息来准确回答这个问题。您如何获取事件以及如何使用这些事件来尝试获取电子邮件地址?组织者是否是您组织的成员......因为它不必是。我觉得信息已经在活动详情中了。
  • 名称John Doe 可能不明确。也许您可以尝试使用Get-Mailbox cmdlet 上的-Anr 参数对字符串“John Doe”进行模糊名称解析搜索?
  • 抱歉耽搁了伙计们 - 我已经添加了完整的脚本

标签: powershell exchange-server


【解决方案1】:

这是我用来获取组织者电子邮件地址的信息

 Get-ADUser -Filter {SamAccountName -like "*John Doe*"}

【讨论】:

    猜你喜欢
    • 2013-12-24
    • 1970-01-01
    • 1970-01-01
    • 2017-04-19
    • 1970-01-01
    • 2017-07-23
    • 1970-01-01
    • 2022-07-27
    • 1970-01-01
    相关资源
    最近更新 更多