Azure Powershell未创建具有多个端口的NSG规则
我正在向NSG添加一个安全规则,该规则允许访问端口423911281129。通过Azure门户,它可以工作。通过Powershell,它拒绝了 我使用以下代码获取NSG,添加安全规则并更新NSGAzure Powershell未创建具有多个端口的NSG规则,azure,powershell,Azure,Powershell,我正在向NSG添加一个安全规则,该规则允许访问端口423911281129。通过Azure门户,它可以工作。通过Powershell,它拒绝了 我使用以下代码获取NSG,添加安全规则并更新NSG $nsg = Get-AzNetworkSecurityGroup -Name "BITH-DEV-T1NSG" - ResourceGroupName "RG-BITH-HANA-POC" $nsg | Add-AzNetworkSecurityRuleConfig -Name "SUM6" -D
$nsg = Get-AzNetworkSecurityGroup -Name "BITH-DEV-T1NSG" -
ResourceGroupName "RG-BITH-HANA-POC"
$nsg | Add-AzNetworkSecurityRuleConfig -Name "SUM6" -Description "Allow
SUM" -Access "Allow" -Protocol * -Direction "Inbound" -Priority "105" -
SourceAddressPrefix * -SourcePortRange * -DestinationAddressPrefix * -
DestinationPortRange "1128,1129,4239"
$nsg | Set-AzNetworkSecurityGroup
当更新NSG时,它给了我以下错误
Set-AzNetworkSecurityGroup : Security rule has invalid Port range. Value
provided: 4239,1128,1129. Value should be an integer OR integer range
with '-' delimiter.Valid range 0-65535.
是否可以通过Powershell向NSG添加自定义范围?您应该提供一个数组作为输入,而不是带有逗号的字符串:
-DestinationPortRange (1128, 1129, 4239)
或者使用“1128”、“1129”、“4239”
,如果它没有自动将它们转换为字符串DestinationPortRange
接受数组
阅读:您应该提供一个数组作为输入,而不是带有逗号的字符串:
-DestinationPortRange (1128, 1129, 4239)
或者使用“1128”、“1129”、“4239”
,如果它没有自动将它们转换为字符串DestinationPortRange
接受数组
阅读:hi,这是如何制作成ps数组的,例如,我需要在$range中传递它们,其中包含“1128”、“1129”、“4239”谢谢,我不确定我是否遵循
(112811294239)
是一个ps数组我很抱歉,这是我想要的,而不是-DestinationPortRange(112811294239),-DestinationPortRange$values问题:$values=1,2,3$nsg |添加AzNetworkSecurityRuleConfig-DestinationPortRange$values
hi,如何将其放入ps数组,例如,我需要在$range中传递它们,其中包含“1128”、“1129”、“4239”谢谢,我不确定是否遵循(112811294239)
是一个ps数组我很抱歉,这是我想要的,而不是-DestinationPortRange(112811294239),-DestinationPortRange$values问题:$values=1,2,3$nsg |添加AzNetworkSecurityRuleConfig-DestinationPortRange$值