【问题标题】:Azure Resource Manager Network Security Group Configuration using Powershell使用 Powershell 的 Azure 资源管理器网络安全组配置
【发布时间】:2016-06-20 08:19:58
【问题描述】:

我需要禁用在 RDP 和 SSH 端口打开的网络安全组下配置的一些规则。我在删除规则配置时遇到了一些问题:

这是我执行的命令:

Get-AzureRmNetworkSecurityGroup -Name $securityGroupName -ResourceGroupName $resourceGroupName | Remove-AzureRmNetworkSecurityRuleConfig -Name $enabledSecurityRDPRule.Name

但是,当我检查门户或执行 get cmdlet 时,我没有看到之前的命令生效。

我什至尝试使用 Set-AzureRmNetworkSecurityRuleConfig 将访问权限设置为拒绝并得到相同的结果。

我用来访问我的环境的服务主体具有贡献者权限。

【问题讨论】:

    标签: powershell azure


    【解决方案1】:

    Remove-AzureRmNetworkSecurityRuleConfig 命令只是从本地 NSG 对象中删除规则。要同步云端,需要运行Set-AzureRmNetworkSecurityGroup

    这是一个完整的脚本。

    $nsg = Get-AzureRmNetworkSecurityGroup -Name <your nsg name> `
                      -ResourceGroupName <your resource group name>
    
    $nsg = Remove-AzureRmNetworkSecurityRuleConfig -Name <your rule name> `
                      -NetworkSecurityGroup $nsg
    
    Set-AzureRmNetworkSecurityGroup -NetworkSecurityGroup $nsg
    

    【讨论】:

      猜你喜欢
      • 2017-05-19
      • 1970-01-01
      • 2020-12-20
      • 1970-01-01
      • 1970-01-01
      • 2016-02-22
      • 2017-05-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多