Exchange Server 命令行

加载exchange模块:
PS C:\Users\administrator.91XUEIT> Add-PSSnapin *exchange*

查看2021/7/28 9:00-11:00 王伟的发件记录:
Get-MessageTrackingLog -ResultSize unlimited -Start "07/28/2021 09:00:00" -End "07/28/2021 11:00:00" -EventId "send" -Sender "wangwei@contoso.com"

查看2021/7/28 9:00-11:00 王伟的发件详情:
Get-MessageTrackingLog -ResultSize unlimited -Start "07/28/2021 09:00:00" -End "07/28/2021 11:00:00" -EventId "send" -Sender "wangwei@contoso.com" | fl

查看禁用的邮箱:
Get-MailboxDatabase | Get-MailboxStatistics | where {$_.disconnectReason -eq "Disabled"}

导出 hanligang 的邮件:
New-MailboxExportRequest -Mailbox hanligang -FilePath \\localhost\c$\hanligang.pst

查看导出的状态:
Get-MailboxExportRequest

在新窗口中查看帮助:
PS C:\Users\administrator.91XUEIT> help New-MailboxExportRequest -ShowWindow

清空 hanligang 的邮箱:
PS C:\Users\administrator.91XUEIT> Search-Mailbox -Identity hanligang -DeleteContent

导入邮件:
New-MailboxImportRequest -Mailbox hanligang -FilePath \\localhost\s\hanligang.pst


[PS] C:\>(dir \\localhost\s\*.pst).BaseName
hanligang
[PS] C:\>(dir \\localhost\s\*.pst).FullName
\\localhost\s\hanligang.pst

批量导入:
[PS] C:\>dir \\localhost\s\*.pst | %{ New-MailboxImportRequest -Name RecoveredPST -BatchName recovered -Mailbox $_.BaseName -FilePath $_.FullName -TargetRootFolder SubFolderInPrimary}

 删除csv文件里所有邮箱里的主题为 "明天放假1天" 邮件:
PS C:\> Import-Csv -Path 'C:\a.csv' |foreach {Search-Mailbox -SearchQuery '主题:"明天放假1天"' -DeleteContent -Identity $_.Email -Force}

显示所有的邮箱地址:
Get-Mailbox | FL Alias

查看全局附件大小设置:
Get-TransportConfig | Format-List MaxReceiveSize,MaxSendSize,MaxRecipientEnvelopeLimit

导出某个群组里的所有成员的中文名、域账号与邮箱地址:

Get-DistributionGroupMember -Identity "上海办公室" | Select Name, SamAccountName, PrimarySmtpAddress | Export-CSV -Encoding UTF8  2.csv –NoTypeInformation

导出bob从2018年1月1日到2022年10的邮件:
New-MailboxExportRequest -Mailbox bob -ContentFilter "(Received -lt '10/01/2022') -and (Received -gt '01/01/2018')" -FilePath "\\host1\bob.pst"

查看、删除指定主题的定期会议:
Search-Mailbox -Identity wangcanfang@geexfinance.com -SearchQuery 'Subject:"车信贷周会" AND Kind:meetings' -TargetMailbox administrator -TargetFolder search -LogLevel Full
Search-Mailbox -Identity wangcanfang@geexfinance.com -SearchQuery 'Subject:"车信贷周会" AND Kind:meetings' -TargetMailbox administrator -TargetFolder search -LogLevel Full -DeleteContent

 

posted @ 2021-07-28 10:53  Peter_Yi  阅读(170)  评论(0)    收藏  举报