首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Powershell -为WMI创建GPO防火墙规则

Powershell -为WMI创建GPO防火墙规则
EN

Stack Overflow用户
提问于 2020-09-16 12:29:44
回答 1查看 795关注 0票数 2

我想通过Powershell创建下面的GPO防火墙规则

下面是现有规则的属性(我想用powershell创建)

代码语言:javascript
运行
复制
Get-NetFirewallRule | where {$_.Name -like "WMI*"}


Name                  : WMI-RPCSS-In-TCP
DisplayName           : Windows Management Instrumentation (DCOM-In)
Description           : Inbound rule to allow DCOM traffic for remote Windows Management Instrumentation. [TCP 135]
DisplayGroup          : Windows Management Instrumentation (WMI)
Group                 : @FirewallAPI.dll,-34251
Enabled               : True
Profile               : Domain, Private, Public
Platform              : {}
Direction             : Inbound
Action                : Allow
EdgeTraversalPolicy   : Block
LooseSourceMapping    : False
LocalOnlyMapping      : False
Owner                 : 
PrimaryStatus         : OK
Status                : The rule was parsed successfully from the store. (65536)
EnforcementStatus     : NotApplicable
PolicyStoreSource     : PersistentStore
PolicyStoreSourceType : Local

    
Name                  : WMI-ASYNC-In-TCP
DisplayName           : Windows Management Instrumentation (ASync-In)
Description           : Inbound rule to allow Asynchronous WMI traffic for remote Windows Management Instrumentation. [TCP]
DisplayGroup          : Windows Management Instrumentation (WMI)
Group                 : @FirewallAPI.dll,-34251
Enabled               : True
Profile               : Domain, Private, Public
Platform              : {}
Direction             : Inbound
Action                : Allow
EdgeTraversalPolicy   : Block
LooseSourceMapping    : False
LocalOnlyMapping      : False
Owner                 : 
PrimaryStatus         : OK
Status                : The rule was parsed successfully from the store. (65536)
EnforcementStatus     : NotApplicable
PolicyStoreSource     : PersistentStore
PolicyStoreSourceType : Local

下面是我创建这些规则之一的代码

代码语言:javascript
运行
复制
$GpoName = "Global-WinRM"
$PolicyStoreName = "abc.com\" + $GpoName
$GpoSessionName = Open-NetGPO –PolicyStore $PolicyStoreName
New-NetFirewallRule -Name "Windows Management I" -DisplayName "Windows Management Instrumentation (ASync-In)" -DisplayGroup  "Windows Management Instrumentation (WMI)" -Group "%systemroot%\system32\wbem\unsecapp.exe" -Profile Domain -Action Allow -GPOSession $GpoSessionName -Verbose

错误:

新的-NetFirewallRule规则:系统找不到指定的文件。一行:1字符:1

  • New-NetFirewallRule -Name“-DisplayName”窗口...
    • CategoryInfo : ObjectNotFound:(MSFT_NetFirewallRule:root/standardcimv2/MSFT_NetFirewallRule) New-NetFirewallRule,CimException + FullyQualifiedErrorId : Windows系统错误2,New-NetFirewallRule
EN

Stack Overflow用户

回答已采纳

发布于 2020-09-16 14:38:18

忘记添加-Program参数

代码语言:javascript
运行
复制
$GpoName = "Global-WinRM"
$PolicyStoreName = "abc.com\" + $GpoName
$GpoSessionName = Open-NetGPO –PolicyStore $PolicyStoreName
New-NetFirewallRule -Name "Windows Management I" -DisplayName "Windows Management Instrumentation (ASync-In)" -Group "@FirewallAPI.dll,-34251" -Program "%systemroot%\system32\wbem\unsecapp.exe" -Profile Domain -Action Allow -GPOSession $GpoSessionName -Verbose
Save-NetGPO -GPOSession $GpoSessionName
票数 0
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63920122

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档