New-NetFirewallRule TechNet文章说明了有关New-NetFirewallRule命令行开关的-Group参数:
[…] This
parameter specifies the source string for the displayGroup parameter.
[…] Rule groups can be used to
organize rules by influence and allows batch rule modifications. Using
the Set-NetFirewallRule cmdlets,if the group name is specified for a
set of rules or sets,then all of the rules or sets in that group
receive the same set of modifications. It is a good practice to
specify this parameter value with a universal and world-ready indirect
@FirewallAPI name.Note: The displayGroup parameter cannot be specified upon object
creation using the New-NetFirewallRule cmdlet,but can be modified
using dot-notation and the Set-NetFirewallRule cmdlet.
听起来有机会,对吧?在尝试了解如何自己完成此操作时,我运行了以下内容:
Get-NetFirewallRule -displayName "Core Networking - IPv6 (IPv6-In)" | Get-Member
…并注意到displayGroup属性只有Get方法,但Group属性(带有RuleGroup别名)同时具有Get和Set方法.
PowerShell解决方案如下:
感谢@maoizm,此解决方案现在可用于存在一个或多个具有相同displayName的规则:
$RuleName = "NameOfYourFirewallRuleGoesHere" $RuleGroup = "YourGroupNameGoesHere" Get-NetFirewallRule -displayName $RuleName | ForEach { $_.Group = '$RuleGroup'; Set-NetFirewallRule -InputObject $_ }
这实际上会创建一个分配给您的规则的新组名.
注意:netsh命令没有add group命令.请在此处查看Netsh AdvFirewall Firewall Commands的语法.
原文地址:https://www.jb51.cc/windows/368061.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。