如何使用AzureRm PowerShell在一个规则中提供多个IP?

如何使用AzureRm PowerShell在一个规则中提供多个IP?,azure,azure-powershell,azure-rm,Azure,Azure Powershell,Azure Rm,我可以使用以下代码在我的网络安全组中成功地为一个源IP地址$SourceAddressPrefix=x.x.x.x配置单个规则: 我想为多个IP配置此单一规则,但当我提供$SourceAddressPrefix=x.x.x.x,y.y.y.y时,正如我在Azure Portal中以交互方式所做的那样,我遇到了以下错误: …具有无效的地址前缀。提供的值:x.x.x.x,y.y.y.y 问题: 如何在一个规则中提供多个IP,就像在Azure Portal中一样?您需要为它提供一个值数组,因为它需要S

我可以使用以下代码在我的网络安全组中成功地为一个源IP地址$SourceAddressPrefix=x.x.x.x配置单个规则:

我想为多个IP配置此单一规则,但当我提供$SourceAddressPrefix=x.x.x.x,y.y.y.y时,正如我在Azure Portal中以交互方式所做的那样,我遇到了以下错误:

…具有无效的地址前缀。提供的值:x.x.x.x,y.y.y.y

问题:


如何在一个规则中提供多个IP,就像在Azure Portal中一样?

您需要为它提供一个值数组,因为它需要System.Collections.Generic.List1[System.String]:


您需要给它一个值数组,因为它需要System.Collections.Generic.List1[System.String]:

你可以用这个$sourcePrefix=x.x.x.x,y.y.y.y.这个在我这边行得通

$nsg = Get-AzureRmNetworkSecurityGroup -ResourceGroupName "xxx" -Name "xxx"
$name = "port_1433"
$priority = 600
$sourcePrefix = "1.1.1.1","2.2.2.2"
$destinationPortRange ="1433"
Set-AzureRmNetworkSecurityRuleConfig -NetworkSecurityGroup $nsg  -Name $name `
    -Direction Inbound  `
    -Priority $priority `
    -Access Allow  `
    -SourceAddressPrefix $sourcePrefix `
    -SourcePortRange *  `
    -DestinationAddressPrefix * `
    -DestinationPortRange $destinationPortRange `
    -Protocol TCP 
$nsg | Set-AzureRmNetworkSecurityGroup
你可以用这个$sourcePrefix=x.x.x.x,y.y.y.y.这个在我这边行得通

$nsg = Get-AzureRmNetworkSecurityGroup -ResourceGroupName "xxx" -Name "xxx"
$name = "port_1433"
$priority = 600
$sourcePrefix = "1.1.1.1","2.2.2.2"
$destinationPortRange ="1433"
Set-AzureRmNetworkSecurityRuleConfig -NetworkSecurityGroup $nsg  -Name $name `
    -Direction Inbound  `
    -Priority $priority `
    -Access Allow  `
    -SourceAddressPrefix $sourcePrefix `
    -SourcePortRange *  `
    -DestinationAddressPrefix * `
    -DestinationPortRange $destinationPortRange `
    -Protocol TCP 
$nsg | Set-AzureRmNetworkSecurityGroup

这基本上是复制我的答案。为什么?这基本上是复制我的答案。为什么?
$nsg = Get-AzureRmNetworkSecurityGroup -ResourceGroupName "xxx" -Name "xxx"
$name = "port_1433"
$priority = 600
$sourcePrefix = "1.1.1.1","2.2.2.2"
$destinationPortRange ="1433"
Set-AzureRmNetworkSecurityRuleConfig -NetworkSecurityGroup $nsg  -Name $name `
    -Direction Inbound  `
    -Priority $priority `
    -Access Allow  `
    -SourceAddressPrefix $sourcePrefix `
    -SourcePortRange *  `
    -DestinationAddressPrefix * `
    -DestinationPortRange $destinationPortRange `
    -Protocol TCP 
$nsg | Set-AzureRmNetworkSecurityGroup