积极答复者
请问各位有没有什么方法,可以清理长时间不使用的邮件组

问题
答案
-
是的,这应该就是问题所在。
去掉source这个参数,然后eventid改成submit。最终的脚本应该是:
$Groups = Get-distributiongroup | select PrimarySmtpAddress $Data = @() Foreach($Group in $Groups){$Data +=get-messagetrackinglog -recipients $Group.PrimarySmtpAddress -resultsize unlimited -EventId SUBMIT | select @{Expression={$_.recipients};Label="recipients";},timestamp | sort timestamp} $Select= $Data | select -first 20 Foreach($Delete in $Select) {Get-distributiongroup $Delete.recipients | select name | Export-CSV c:\1.csv -Notypeinformation}
此致,
敬礼
Manu Meng
如果以上回复对您有所帮助,建议您将其“标记为答复”. 如果您对我们的论坛支持有任何的建议,可以通过此邮箱联系我们:tnsf@microsoft.com.
- 已标记为答案 此间少年 2018年8月28日 6:01
全部回复
-
您好,
这个问题可以用如下脚本实现,找到接收邮件时间最久远的前20个组,然后把他们删除,具体的数字可以根据需求自动调整:
$Groups = Get-distributiongroup | select PrimarySmtpAddress $Data = @() Foreach($Group in $Groups){$Data +=get-messagetrackinglog -recipients $Group.PrimarySmtpAddress -resultsize unlimited -EventId receive -source smtp |select @{Expression={$_.recipients};Label="recipients";},timestamp | sort timestamp} $Select= $Data | select -first 20 Foreach($Delete in $Select) {Get-distributiongroup $Delete.recipients | Remove-distributiongroup -confirm:$false}
此致,
敬礼
Manu Meng
如果以上回复对您有所帮助,建议您将其“标记为答复”. 如果您对我们的论坛支持有任何的建议,可以通过此邮箱联系我们:tnsf@microsoft.com.
- 已编辑 Manu MengModerator 2018年8月17日 3:21
- 已建议为答案 Manu MengModerator 2018年8月17日 3:21
-
您好,
那您查看单封邮件的Message Tracking Log会有问题吗?我这里测试是不会报错的。你可以现在发一封测试邮件确认一下:
get-messagetrackinglog -recipients "<username.domain.com>" -MessageSubject "<subject>"
>>这个脚本能否修改一下,把不经常使用的邮件组直接导出到本地,由管理员确认是否删除,而不直接删除。可以的。最后一行改为:
Foreach($Delete in $Select) {Get-distributiongroup $Delete.recipients | select name | Export-CSV c:\1.csv -Notypeinformation}
此致,
敬礼
Manu Meng
如果以上回复对您有所帮助,建议您将其“标记为答复”. 如果您对我们的论坛支持有任何的建议,可以通过此邮箱联系我们:tnsf@microsoft.com.
- 已编辑 Manu MengModerator 2018年8月21日 8:53
- 已建议为答案 Manu MengModerator 2018年8月22日 11:20
-
你好,我查了一下 -soure 这个参数是适用于exchange server 2016的,而我使用的是exchange server 2013,请问是否和这个有关呢?
-SourceThe Source parameter filters the message tracking log entries by the value of the Source field. These values indicate the transport component that's responsible for the message tracking event. For more information, see Source values in the message tracking log (https://technet.microsoft.com/library/bb124375.aspx#Source).
Type: String "box-sizing:inherit;word-wrap:break-word;padding:14px 0px;line-height:1.5;vertical-align:top;border-width:1px 0px 0px;border-style:solid;border-color:#e0e0e0;float:none;width:567px;">Named Default value: None Accept pipeline input: False Accept wildcard characters: False Applies to: Exchange Server 2016 -
是的,这应该就是问题所在。
去掉source这个参数,然后eventid改成submit。最终的脚本应该是:
$Groups = Get-distributiongroup | select PrimarySmtpAddress $Data = @() Foreach($Group in $Groups){$Data +=get-messagetrackinglog -recipients $Group.PrimarySmtpAddress -resultsize unlimited -EventId SUBMIT | select @{Expression={$_.recipients};Label="recipients";},timestamp | sort timestamp} $Select= $Data | select -first 20 Foreach($Delete in $Select) {Get-distributiongroup $Delete.recipients | select name | Export-CSV c:\1.csv -Notypeinformation}
此致,
敬礼
Manu Meng
如果以上回复对您有所帮助,建议您将其“标记为答复”. 如果您对我们的论坛支持有任何的建议,可以通过此邮箱联系我们:tnsf@microsoft.com.
- 已标记为答案 此间少年 2018年8月28日 6:01
-
这个脚本执行之后,没有出现报错。但是还有问题,就是执行完成后,没有导出数据,也没有创建1.csv文件。麻烦您再看一下,感谢!!
换一个路径试试,不要直接放到C盘,新建一个文件夹,C:\folder\1.csv。把first的值调小一些,-first 20 变为-first 5。
此致,
敬礼
Manu Meng
如果以上回复对您有所帮助,建议您将其“标记为答复”. 如果您对我们的论坛支持有任何的建议,可以通过此邮箱联系我们:tnsf@microsoft.com.
- 已编辑 Manu MengModerator 2018年8月23日 10:00
- 已标记为答案 此间少年 2018年8月28日 6:01
- 取消答案标记 此间少年 2018年8月28日 6:01