简体   繁体   English

需要帮助在 Azure 防火墙中添加规则 Powershell

[英]Need help to add rule in Azure Firewall Powershell

I am trying to add a rule in azure firewall.我正在尝试在 azure 防火墙中添加规则。 I have azure firewall policy where I have create network rule collection then inside the collection i have rules added.我有 azure 防火墙策略,我在其中创建了网络规则集合,然后在集合中添加了规则。 I would like add one more rule in the same network rule collection.我想在同一个网络规则集合中再添加一个规则。 I am using the below script to do我正在使用下面的脚本来做

$rule = New-AzFirewallNetworkRule -Name "AllowAzureDevOps" -Description "Allow access to Azure Devops" -SourceAddress "10.0.0.0/16" -DestinationAddress AzureDevOps -DestinationPort 443 -Protocol TCP

$policy = Get-AzFirewallPolicy -Name "fw-policy" -ResourceGroupName "fw-rg"

$networkrulecollectiongroup = Get-AzFirewallPolicyRuleCollectionGroup -Name "DefaultNetworkRuleCollectionGroup" -ResourceGroupName "fw-rg" -AzureFirewallPolicyName "fw-pol"

$existingrulecollection = $networkrulecollectiongroup.Properties.RuleCollection | where {$_.Name -eq "NetworkRuleCollection"}

$existingrulecollection.Rules.Add($rule)

PS C:\Users\mkumar480> $existingrulecollection.Rules.Add($rule) PS C:\Users\mkumar480> $existingrulecollection.Rules.Add($rule)

Cannot find an overload for "Add" and the argument count: "1".找不到“添加”和参数计数的重载:“1”。 At line:1 char:1在行:1 字符:1

  • $existingrulecollection.Rules.Add($rule) $existingrulecollection.Rules.Add($rule)
  •  + CategoryInfo: NotSpecified: (:) [], MethodException + FullyQualifiedErrorId: MethodCountCouldNotFindBest

Try the AddRule method试试AddRule方法

$existingrulecollection.AddRule($rule)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM