簡體   English   中英

Powershell-組織者的電子郵件地址

[英]Powershell - Organizer Email Address

我正在嘗試使用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

請協助!

這是我用來獲取組織者電子郵件地址的地址

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM