I want to create below GPO Firewall rules via Powershell
Here are properties of existing rules (i want to create with powershell)
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
Here is my code for creating one of those rules
$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
Error:
New-NetFirewallRule : The system cannot find the file specified. At line:1 char:1
- New-NetFirewallRule -Name "Windows Management I" -DisplayName "Window ...
-
+ CategoryInfo : ObjectNotFound: (MSFT_NetFirewallRule:root/standardcimv2/MSFT_NetFirewallRule) [New-NetFirewallRule], CimException + FullyQualifiedErrorId : Windows System Error 2,New-NetFirewallRule
