Exchange Server 2013 运维系列——EMS实用命令收集(持续更新中...)

Exchange Management Shell 实用命令收集如下:


( 注: 1、以下命令均以“管理员身份”运行         2、以下命令行中的中文名称均以实例名称替换 


一、启用邮箱:


1、批量启用邮箱帐户:


启用AD中所有未启用的用户:

Get-User -RecipientTypeDetails User -Filter { UserPrincipalName -ne $Null } | Enable-Mailbox -Database "数据库名称"


启用AD中某个组织单位下面的用户:

Get-User -OrganizationalUnit "组织单位名称" | Enable-Mailbox -Database "数据库名称"


2、指定帐户启用邮箱帐户:


Enable-Mailbox -Identity 域名\用户名 -Database "数据库名称"


3、获取已经创建的邮箱


Get-Mailbox | FL Name,RecipientTypeDetails,PrimarySmtpAddress


4、禁用邮箱:


Disable-Mailbox [email protected]

二、邮件收发速度设置:


1、获取各连接器的邮件收发速度


Get-ReceiveConnector | ft Name,MessageRateLimit


2、设置每分钟邮件收发速度:


Get-ReceiveConnector "服务器名称\连接器名称" | Set-ReceiveConnector -MessageRateLimit 100

此处设置每分钟发100封邮件


三、邮件操作:


前提条件:http://blog.csdn.net/xiezuoyong/article/details/9792277


1、删除用户邮箱中所有的邮件内容


提升对指定数据库中的所有用户的操作权限:

get-mailbox -Database "数据库名" | add-mailboxpermission -user 域名\administrator -AccessRights FullAccess -InheritanceType all

单个删除命令:

Search-Mailbox -Identity "邮箱名" -DeleteContent


按主题包含的关键字删除:


Search-Mailbox -Identity "April Stewart" -SearchQuery "Subject:'关键字'" -DeleteContent


批量删除:

get-mailbox -Database "数据库名" | Search-Mailbox -DeleteContent


2、移动邮箱用户到另一个数据库:


提升对指定数据库中的所有用户的操作权限:


get-mailbox -Database "数据库名" | add-mailboxpermission -user 域名\administrator -AccessRights FullAccess -InheritanceType all


移动命令:


New-MoveRequest -Identity "邮箱用户" -TargetDatabase '数据库名称'


3、导出邮件到pst文件:


单个邮箱导出:


New-MailboxExportRequest -Mailbox "邮箱用户名" -FilePath "\\192.168.12.8\mail\test.pst"


单个邮箱导入:


New-MailboxImportRequest -Mailbox "邮箱用户名" -FilePath "\\192.168.12.8\mail\test.pst"


指量导出:


Get-mailbox | export-mailbox –PSTFolderPath C:\mailboxes


批量导入:


Dir C:\Mailboxes | import-mailbox –PSTFolderPath C:\mailboxes


四、邮箱配额设置:


Set-Mailbox -Identity "Joe Healy" -IssueWarningQuota 0.9gb -ProhibitSendQuota 1gb -ProhibitSendReceiveQuota 1.2gb -UseDatabaseQuotaDefaults $false


IssueWarningQuota 设置“发出警告限制ProhibitSendQuota 设置“禁止发送限制”,ProhibitSendReceiveQuota 设置“禁止发送和接收限制”。


获取邮箱配额设置:


Get-Mailbox -identity "用户名" | fl IssueWarningQuota,ProhibitSendQuota,ProhibitSendReceiveQuota


五、配置连接器:


Set-ReceiveConnector -Identity "连接器名称" -MaxInboundConnectionPerSource unlimited


MaxInboundConnectionPerSource 參數指定這個接收連接器同時從單一 IP 位址服務的輸入連線數目上限。預設值是 20。此參數的有效輸入範圍是 1 到 10000。若要停用接收連接器上的每個來源輸入連線限制,請輸入值 unlimited


六、获取所有邮箱使用情况,按大小排序


Get-Mailbox | Get-Mailboxstatistics | Sort-Object TotalItemSize -Descending | ft DisplayName,@{label="TotalItemSize(KB)";expression={$_.TotalItemSize.Value.ToKB()}},ItemCount >c:\log\shmailboxes.csv


七、获取邮箱帐户的GUID:


1、通过用户名找GUID:


get-mailbox -identity "用户名" | fl name,guid


2、批量查找所有用户的GUID:


get-mailbox | fl name,guid


八、收件人筛选:


1、启用收件人筛选:


Set-RecipientFilterConfig -Enabled $false


2、禁用收件人筛选:

Set-RecipientFilterConfig -Enabled $false


3、验证收件人筛选:


Get-RecipientFilterConfig | Format-List Enabled


4、启用或禁用收件人查找:


Set-RecipientFilterConfig -RecipientValidationEnabled <$true | $false>


5、验证收件人查找:


Get-RecipientFilterConfig | Format-List RecipientValidationEnabled


九、发件人筛选:


1、启用发件人筛选:


Set-SenderFilterConfig -Enabled $true

2、禁用发件人筛选:


Set-SenderFilterConfig -Enabled $false

3、验证发件人筛选:


Get-SenderFilterConfig | Format-List Enabled

4、阻止发件人和域:


Set-SenderFilterConfig -BlockedSenders [email protected],[email protected] -BlockedDomains fabrikam.com -BlockedDomainsAndSubdomains northwindtraders.com


此示例将配置发件人筛选器代理,以阻止来自 [email protected][email protected] 的邮件、来自 fabrikam.com 域的邮件以及来自 northwindtraders.com 及其所有子域的邮件。


5、要在不修改任何现有值的情况下添加或删除条目


Set-SenderFilterConfig -BlockedSenders @{Add="[email protected]","[email protected]"} -BlockedDomains @{Remove="tailspintoys.com"} -BlockedDomainsAndSubdomains @{Add="blueyonderairlines.com"}

本示例将使用以下信息配置发件人筛选器代理:

[email protected][email protected] 添加到被阻止的现有发件人列表。

从被阻止的现有发件人域列表中删除 tailspintoys.com。

将 blueyonderairlines.com 添加到被阻止的现有发件人域和子域列表。


6、验证您是否已成功配置阻止发件人


Get-SenderFilterConfig | Format-List BlockedSenders,BlockedDomains,BlockedDomainsAndSubdomains

7、启用或禁用阻止发件人为空的邮件


Set-SenderFilterConfig -BlankSenderBlockingenabled <$true | $false>

8、验证是否成功启用或禁用了阻止发件人为空的邮件


Get-SenderFilterConfig | Format-List BlankSenderBlockingEnabled



转载请注明出处:http://blog.csdn.net/xiezuoyong/article/details/9701417


你可能感兴趣的:(Exchange)