«   2024/12   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
Tags more
Archives
Today
Total
12-28 16:41
관리 메뉴

+1-1+1-1+1-1+1-1...

Exchange 2013 - 특정 그룹 메시지 수/발신 건수 추출(2) 본문

NT/Mail & Exchange

Exchange 2013 - 특정 그룹 메시지 수/발신 건수 추출(2)

투명인간 2021. 3. 5. 21:36
728x90

시나리오

대상 : extensionattribute15=1860인 Ad 메일 계정

추출 범위 : 특정월 기준 @testlab.net에서 외부 메일로 발송된 메시지 로그 추출하기

 

$result = @()
$senders = @()
$count = 0
$servers = @()
$senders = (Get-ADUser -LDAPFilter "(&(objectclass=user)(mail=*)(extensionattribute15=1860))" `
-SearchScope Subtree -SearchBase "OU=testlab,DC=testlab,DC=net" | `
where {$_.enabled -eq $true }).UserPrincipalName | get-mailbox | `
Select WindowsEmailAddress
Write-Host "Senders Imported"
#$servers = Get-ClientAccessServer | ?{$_.name -ne "UM-MAILIN01"} 

$servers = Get-ClientAccessServer 
Write-Host "Getting CAS Server List..."

foreach($server IN $servers){
Write-Host "Starting to get trackinglogs In " + $server + "..."
    foreach($sender IN $senders)
    {
        $count += 1
        # 진행률 표시
        Write-Host "Working... : " $sender.WindowsEmailAddress " (" $Server ") " `
        			(($count/($senders.Count*21))*100)%
        $sendresult_ex += (Get-MessageTrackingLog -Server $server -ResultSize `
        					unlimited -Sender $sender.WindowsEmailAddress.ToString() `
                            -Start "2021-03-01 00:00:00" -End "2021-03-31 23:59:59" `
                            -EventId SEND | ?{$_.Recipients -notlike '*@testlab.net'} | `
                            select Timestamp, Sender, `
                            @{Name=’Recipients‘; Expression={[string]::join(“;”, ($_.Recipients))}}, `
                            MessageSubject )
	}
}

Write-Host "Starting to export logs..."
$sendresult_ex | Export-Csv \\로그저장서버\C:\대외발송로그.csv -Encoding UTF8 `
				-NoTypeInformation -force 
Write-Host "All done"

 

반응형