简体   繁体   English

Powershell-组织者的电子邮件地址

[英]Powershell - Organizer Email Address

I'm trying to retrieve the email address of the Organizer of a meeting in MS Exchange 2010, using Powershell. 我正在尝试使用Powershell检索MS Exchange 2010中的会议组织者的电子邮件地址。

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

I get the below error 我得到以下错误

The operation couldn't be performed because object 'John Doe' couldn't be found on 'xxxxxxxxxxxxxx' 无法执行此操作,因为在“ xxxxxxxxxxxxxx”上找不到对象“ John Doe”

These are for meetings that have just been created, so how can the Organizer not exist? 这些是针对刚刚创建的会议的,所以组织者怎么不存在?

Edit: 编辑:

Here's the sequence of events: 这是事件的顺序:

  • Fetch list of calendar events from exchange within specific date range 在特定日期范围内通过交换获取日历事件列表
  • Fetch email address of Organizer for each event <-- this is where I'm stuck 提取每个事件的管理器电子邮件地址<-这就是我遇到的问题

Full script: 完整脚本:

$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

Please assist! 请协助!

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM