简体   繁体   中英

Powershell - Organizer Email Address

I'm trying to retrieve the email address of the Organizer of a meeting in MS Exchange 2010, using Powershell.

(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'

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*"}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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