gpt4 book ai didi

powershell - 如何在 Powershell 中使用 New-NetFirewallRule 复制 RPC 防火墙条目?

转载 作者:可可西里 更新时间:2023-11-01 02:43:19 26 4
gpt4 key购买 nike

我正在为 Windows Server 2012R2 编写部署脚本,它必须复制一些防火墙实体。 New-NetFirewallRule cmdlet 适用于简单的规则,但我无法通过 powershell 使这个自定义规则起作用:

Rule I'm trying to replicate

根据 Technet documentation :

If the Protocol parameter value is TCP or UDP, then the acceptable values for this parameter are:
-- Port range: 0 through 65535.
-- Port number: 80.
-- Keyword: PlayToDiscovery or Any.

If the Protocol parameter value is ICMPv4 or ICMPv6, then the acceptable values for this parameter are:
-- An ICMP type, code pair: 0, 8.
-- Type and code: 0 through 255.
-- Keyword: Any.

If the Protocol parameter is not specified, then the acceptable values for this parameter are: RPC, RPCEPMap, Teredo, IPHTTPSIn, IPHTTPSOut, or Any.

所以我不知道如何定义使用 Protocol=TCP 和 Local Port="RPC Dynamic Ports"的规则。任何人都可以在这里转换一些光吗? :)

最佳答案

我发现将 "RPC" 指定为 -LocalPort 的参数值,将 "TCP" 指定为 -Protocol 参数将创建一个包含您要查找的值的规则。

例子:

New-NetFirewallRule -Name 'Name' -DisplayName 'Name' -Group 'Group' -Profile Domain -Direction Inbound -Action Allow -EdgeTraversalPolicy Block -Protocol 'TCP' -LocalPort 'RPC'

关于powershell - 如何在 Powershell 中使用 New-NetFirewallRule 复制 RPC 防火墙条目?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44565911/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com