DL별 메일 수신 정리용 스크립트
전일자 기준 일주일간 DL메일 수신 리스트 Export
예약작업에 등록하여 사용
# Exchange management Shell Connect # . 'D:\Exchange Server\V15\bin\RemoteExchange.ps1' Connect-ExchangeServer -auto $StartDay = (Get-Date).AddDays(-7).ToString("yyyy-MM-dd") $EndDay = (Get-Date) $EndDayprint = (Get-Date).AddDays(-1).ToString("yyyy-MM-dd") $Path = "C:\Work\Scripts\DLReceive\Export" get-exchangeserver | Get-MessageTrackingLog -start $StartDay -End $EndDay.ToString("yyyy-MM-dd") -ResultSize unlimited -eventid ` expand | select Timestamp,RelatedRecipientAddress,Sender,MessageSubject | export-csv -Encoding UTF8 -Path $Path\DLReceive_$StartDay"_"$EndDayprint.csv -NoTypeInformation get-childitem -path "c:\work\Scripts\DLCleanUp\Export" -exclude childitem.txt -name > "$Path\childitem.txt" $From = "notice@redplug.com" $To = "redplug@redplug.com" $SmtpServer = "mail.redplug.com" $Subject = "[AutoJob] $EndDay DLReceiveListExport End" $Body = get-content -path "$Path\Childitem.txt" | Out-String Send-MailMessage -From $From -To $To -SmtpServer $SmtpServer -Subject $Subject -Body $Body |
DL 리스트 정리
# Exchange management Shell Connect # . 'D:\Exchange Server\V15\bin\RemoteExchange.ps1' Connect-ExchangeServer -auto # 작업 날짜 $Date = (Get-date).toString("yyyyMMdd") # Export path $Path = "C:\Work\Scripts\DLReceive\Export" get-DistributionGroup -resultsize unlimited -filter {HiddenFromAddressListsEnabled -eq "False"} | ` Select SamAccountName, OrganizationalUnit,DisplayName,` HiddenFromAddressListsEnabled,WindowsEmailAddress,WhenCreated | ` export-csv -Encoding UTF8 -Path $Path\AllDLList_$Date.csv -NoTypeInformation |