-----提供AD\Exchange\Lync\Sharepoint\CRM\SC\O365等微软产品实施及外包,QQ:185426445.电话18666943750

需求:需要修改现有的Exchange传输规则,在例外域列表里面批量增加自定义域名

分析:现有的属性没有add属性,于是我们变通下解决,将现有的例外域名取出赋值到1个变量,然后把自定义的所有域名都保存到另外1个变量(如果自定义的域名比较多,可以存到1个TXT文本),在把两个变量值相加后,最后在写入到现有的ExceptIfRecipientDomainIs相关属性。


$Currentdomains=(Get-TransportRule test |select -ExpandProperty ExceptIfRecipientDomainIs).value
#$Newdomains="pingfangtech.com","pingfangtech.net"
$Newdomains=Get-Content c:\add.txt
$Mergelist=$Currentdomains+$Newdomains
Set-TransportRule test -ExceptIfRecipientDomainIs $Mergelist

或者如下格式(直接加自定义域名)

$Currentdomains=Get-TransportRule test |select -ExpandProperty ExceptIfRecipientDomainIs
$Newdomains="baidu.com","hotmail.com"
$Mergelist=$Currentdomains+$Newdomains
Set-TransportRule test -ExceptIfRecipientDomainIs $Mergelist


add.txt文件放到C盘,格式如下:

最终效果如下: