Exchange 2010 기간 전체 메일링 수 집계

Exchange 서버가 주어진 시간 범위(perWeek 7일,perMonth 30일...perSeason 90일 등)에서 수신한 메일의 총수와 총 용량 크기를 집계하여 보고서로 업그레이드 예상을 제출해야 합니다.
해결: 통계 총수는 간단합니다. 명령으로 Meansure를 가져오면count 수량을 출력할 수 있습니다.
# Receive  Send
Get-TransportServer | get-messagetrackinglog -Start "2012/4/1 10:42:00" -End "2012/5/1 00:00:00" -EventId Receive | Measure-object

그러나 용량을 통계하려면 변수를 뽑아 가중해야 한다.TechNet Gallery에서 이 스크립트를 찾았어요.
http://gallery.technet.microsoft.com/scriptcenter/ba5bd64d-6025-415a-86ed-2b51f9aabaf0역할: This script counts the number of e-mails that are sent and received in your Exchange environment per week, including their total size in MB.
직접 가져와 수정하여 우리의 요구에 부합되는 스크립트를 얻을 수 있습니다. 코드는 다음과 같습니다.
 
# Script:	TotalEmailsSentReceivedPerMonth.ps1
# Purpose:	Get the number of e-mails sent and received per week
# Modified Purpose: get the number of e-mails sent and received per 30 days since today before.
# Author:	Nuno Mota
# Date:		October 2010
# Modify:   Soda
# ModifyDate: June 2014

# From date should be a MONDAY
#$From = Get-Date "06/02/2012"
#$To = $From.AddDays(7)

#the $To date initializes as today‘s date, the $To date minus 30 days gives the $From date.
$From = $to.adddays(-30)
$to = get-date

[Int64] $intTotalSentSize = $intTotalSent = 0
[Int64] $intTotalRecSize = $intTotalRec = 0

Write-Host "From, To, # Sent, Size Sent, # Received, Size Received"

#Do
#{
	#Get-ExchangeServer | ? {$_.AdminDisplayVersion -match "8.3" -and $_.IsHubTransportServer -eq $True} | Get-MessageTrackingLog -ResultSize Unlimited -Start $FromSmall -End $ToSmall | ForEach {
	Get-TransportServer | Get-MessageTrackingLog -ResultSize Unlimited -Start $From -End $To | ? {$_.MessageSubject -ne "Folder Content"} | ForEach {
		# Sent E-mails
		If ($_.EventId -eq "RECEIVE" -and $_.Source -eq "STOREDRIVER")
		{
			$intTotalSentSize += $_.TotalBytes
			$intTotalSent++
		}
		
		# Received E-mails
		If ($_.EventId -eq "DELIVER")
		{
			$intTotalRecSize += $_.TotalBytes
			$intTotalRec++
		}
	}

	# Convert the size to MB and round it 
	$intTotalSentSize = [Math]::Round($intTotalSentSize/1MB, 0)
	$intTotalRecSize = [Math]::Round($intTotalRecSize/1MB, 0)

	# Create a TempTo variable as when we are searching the logs we search up to the next day, but we want to print the day before 
	$TempTo = ($To.AddDays(-1)).ToShortDateString()
	$FromSmall = $From.ToShortDateString()
	Write-Host "$FromSmall, $TempTo, $intTotalSent, $intTotalSentSize, $intTotalRec, $intTotalRecSize"

	# Reset the variables to do another search
	#$From = $From.AddDays(7)
	#$To = $From.AddDays(7)
	#$intTotalSentSize = $intTotalSent = 0
	#$intTotalRecSize = $intTotalRec = 0
#}
#While ($To -lt (Get-Date))

 
원래의 코드도 모두 보류하고 주석만 떨어뜨렸다.
우리가 오늘 30일 전의 날짜를 통계해야 하기 때문에, start는 30일 전의 날짜이고, to는 오늘의 날짜이다.
(일수를 늘리는 방법만 있는 줄 알았던 AddDays(), 안에 마이너스를 채우면 일수를 줄이는 방법이 될 줄은 몰랐어요)
더 많은 일수를 집계해야 한다면adddays () 안의 수량을 직접 바꾸십시오.전제 조건은 당신의 MessageTrackingLog가 충분한 시간을 보존하고 있다는 것이다.
코드를 실행한 후 얻은 결과는 다음과 같습니다.
 
TrackingLog 구성 방법:http://technet.microsoft.com/en-us/library/aa997984(v=exchg.150).aspx
현재 서버에서 최대 1.5GB의 로그를 90일 동안 보존하도록 수정했습니다.

좋은 웹페이지 즐겨찾기