浅谈powershell命令-Exchange常用命令

网友投稿 1225 2022-09-13

浅谈powershell命令-Exchange常用命令

浅谈powershell命令-Exchange常用命令

1.查询邮件传输日志

a.条件查询

Get-TransportServer|Get-MessageTrackingLog -Sender '发件人地址' -Recipients "收件人地址" -Start '开始时间' -End '结束时间' -MessageSubject "主题"

b.查询邮件送达至收件人哪个文件夹

$a=Get-TransportServer|Get-MessageTrackingLog -Sender '发件人地址' -Recipients "收件人地址" -Start '开始时间' -End '结束时间' -MessageSubject "主题"$a|select-object rec*

c.导出查询(收件人等以,连接便于导出查看)

$trackinglog=Get-TransportServer|Get-MessageTrackingLog -Sender '发件人地址' -Recipients "收件人地址" -Start '开始时间' -End '结束时间' -MessageSubject "主题"$trackinglogs=$trackinglog|Select-Object PSComputerName,Timestamp,ClientIp,ClientHostname,ServerIp,ServerHostname,SourceContext,ConnectorId,Source,EventId,MessageId,Recipients,RecipientStatus,RecipientCount,RelatedRecipientAddress,Reference,MessageSubject,Sender,ReturnPath,MessageInfo,MessageLatencyType,EventDataforeach($info in $trackinglogs){$info.Recipients=$info.Recipients -join ", "$info.RecipientStatus=$info.RecipientStatus -join ", "$info.Reference=$info.Reference -join ", "$info.EventData=$info.EventData -join ", "}$trackinglogs|Export-Csv -Path 文件路径\trackinglog.csv -NoTypeInformation -Encoding UTF8

2.循环删除大批量堆积邮件队列

#加载Exchange模块,可在powershell ISE运行Add-PSSnapin Microsoft.Exchange*#循环删除for($true){ Foreach($server in $(Get-ClientAccessService|sort)){ Invoke-Command -ScriptBlock { Add-PSSnapin Microsoft.Exchange* Echo "$($server.Name)开始" $未送达数量=$server|Get-Message -ResultSize 5000 |?{($_.Recipients -like "*收件人邮件地址*") -or ($_.FromAddress -like "发件人邮件地址")} #-or ($_.FromAddress -like "*主题*") #需要筛选主题的话把这段加上去 $未送达数量|Remove-Message -WithNDR $False -Confirm:$false $allremove=$未送达数量.count +$allremove Echo "$($server.Name)已完成,删除$($未送达数量.count)" } } sleep 30 #30s睡眠}#Ctrl+C停止运行

3.修改客户端最大连接数

借鉴:​​更改特定用户的用户限制设置:Exchange 2013 帮助 | Microsoft Docs​​

#新建用户限制 151线程New-ThrottlingPolicy -Name UserMaxCount150 -EwsMaxConcurrency 151 -ThrottlingPolicyScope Regular#设置最大连接数 151线程Set-ThrottlingPolicy UserMaxCount150 -EwsMaxConcurrency 151 -OutlookServiceMaxConcurrency 151 -OwaMaxConcurrency 151 -PowerShellMaxConcurrency 151#校验设置Get-ThrottlingPolicy -Name UserMaxCount150 | Format-List#将限制应用到用户(非实时生效)$b=Get-ThrottlingPolicy UserMaxCount150Set-Mailbox -Identity 用户登录名 -ThrottlingPolicy $b#刷新配置Get-Mailbox -Identity 用户登录名|Get-MailboxStatistics | ForEach { Update-StoreMailboxState -Database $_.Database -Identity $_.MailboxGuid -Confirm:$false }

4.取消数据库索引自动分配

借鉴:​​数据库名称 | Set-MailboxDatabase -IsExcludedFromProvisioning $true

5.数据库索引修复

Update-MailboxDatabaseCopy 数据库名/服务器名称 -CatalogOnly

相关索引服务:

Microsoft Exchange Search Host Controller                HostControllerService

Microsoft Exchange Information Store                         MSExchangeIS

Microsoft Exchange 搜索                                             MSExchangeFastSearch

6.刷新数据库命令

刷新某个用户的信息Get-Mailbox -Identity 用户登录名 |Get-MailboxStatistics | ForEach { Update-StoreMailboxState -Database $_.Database -Identity $_.MailboxGuid -Confirm:$false }刷新某个数据库Get-MailboxStatistics -Database 数据库名称 | ForEach { Update-StoreMailboxState -Database $_.Database -Identity $_.MailboxGuid -Confirm:$false }刷新整个服务器所有库Foreach($database in $(Get-MailboxDatabase) ){Get-MailboxStatistics -Database $database.name | ForEach { Update-StoreMailboxState -Database $_.Database -Identity $_.MailboxGuid -Confirm:$false }}

7.查询日历权限

查看权限:get-MailboxFolderPermission -Identity 用户登录名:\日历新增权限:赋予管理员或特定用户会议室邮箱日历的Owner权限:Add-MailboxFolderPermission -Identity 用户登录名:\日历 -User 需赋权用户登录名 -AccessRights Owner

8.设置邮件组最大发送、收件大小

Set-DistributionGroup -Identity 邮件组名称 -MaxSendSize 20MB -MaxReceiveSize 20MB

9.邮件保留策略

参考:​​将保留策略应用于邮箱Exchange Server | Microsoft Docs​​

10.组织内启用邮件已读未读状态查询

参考:​​Exchange用户邮件状态跟踪_望望的技术博客_51CTO博客​​

11.多服务器命令调用

foreach($EXCtime in $(Get-ExchangeServer).OriginatingServer) {Invoke-Command -ComputerName $EXCtime -Scriptblock { 命令}}#思考:需自行加判断脚本,Invoke-Command 不能在把computerName命令指向本机,否则会有问题。

PS:转自本人CSDN账户 :​​https://blog.csdn-/qq_28637975/article/details/124352471?spm=1001.2014.3001.5501​​​​​​

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:G012-OS-WIN-10-02 Windows 10 系统安装
下一篇:Winform中设置ZedGraph的曲线为折线、点折线、散点图(折线统计图横纵轴表示)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~