Powershell - 交换 - 字符串作为多个参数 - Set-SendConnector

问题描述 投票:0回答:1

我对 powershell 和“如何将多个参数传递给一个 Exchange Powershell Comandlet”有疑问。

我们有一个带有多个 SendConnector 的 Exchange 服务器。 每个 SendConnector 有大约 1000 个邮件域。 https://learn.microsoft.com/de-de/powershell/module/exchange/set-sendconnector?view=exchange-ps

假设我有一个变量:

$mailDomains = '"mail1.de","mail2.de","mail3.de"';

如果我“手动”输入命令:

Set-SendConnector -Identity "MyConnectorName001" -AddressSpaces "mail1.de","mail2.de","mail3.de"

这正在起作用。 但如果我想这样做:

Set-SendConnector -Identity "MyConnectorName001" -AddressSpaces $mailDomains

它失败了,因为它将变量作为一个字符串读取

有没有办法为 -AddressSpacecs 多个域提供变量?

我尝试将字符串变量 $mailDomains 拆分为数组 - 没有成功。

我尝试使用以下内容迭代数组

foreach($mailDomain in $mailDomains)
{
    Set-SendConnector -Identity "MyConnectorName001" -AddressSpaces @{add=$mailDomain}
}

该方法有效,但需要 10 分钟才能将所有邮件域添加到一个连接器中。 当我在一个命令中使用包含 1000 个地址的 Set-SendConnector 命令时,每个连接器需要 1 - 2 秒。

powershell exchange-server powershell-remoting
1个回答
0
投票

您提到您已尝试将

$maildomains
拆分为数组,但您没有包含任何有关如何做到这一点的信息。

我认为你正在寻找的语法是:

$mailDomains = @("mail1.de","mail2.de","mail3.de")

因此整个内容都包含在

@()
内,并且两端没有单引号。

© www.soinside.com 2019 - 2024. All rights reserved.