Loading...
Loading...

The component (NetSecurity) is very strong and documented. You have to keep in mind that this tutorial only put on to the Windows operating system. Note, for other operating systems, we have other command and line tools which can be used to carry out the same type of command such as (UFW or IPTables) on Linux.

Processing and Loading the NetSecurity Module

The NetSecurity module practically obtained and presented by the Microsoft, and also contains all of the functionality which is needed to add, remove, and also modify the firewall rules in other to load the module, just simply import the module as display below.

Import-Module -Name ‘NetSecurity’

List the Existing Firewall Rules

The cmdlet, you Get-NetFirewallRule will then display all existing firewall rules. There are very many, by default, in demonstrating, we will output the first 10.

Command: Get-NetFirewallRule | Select-Object DisplayName, Enabled, Direction, Action -First 10

There are different properties that are returned by toggling the Get-NetFirewallRule. However we listed only a few properties above, running the Get-NetFirewallRule | Select-Object * -First 1, will list all the available.

Advertisements
Loading...

Creating a New Firewall Rule

There are so many ways in which you can create a new Firewall rule but the command that is in charge of all this is the (Net-NewFirewallRule)(<https://docs.microsoft.com/en-us/powershell/module/netsecurity/new-netfirewallrule?view=win10-ps>). And is basic possessions that need to be filled in are:

  • The DisplayName – The reserved name of the firewall rule
  • The Direction–eider by blocking the traffic leaving the computer, Outbound or coming into the computer Inbound
  • The Action– What action/command  to take if the rule is met, Allowing or Blocking
  • $Params = @{ “DisplayName” = ‘Block WINS’ “Direction” = ‘Inbound’ “Action” = ‘Block’ “RemoteAddress” = ‘WINS’ }
  • The New-NetFirewallRule @Params
    If the given Namerestriction is not used, and in place of it a random GUID is used. Then the Display name may be human-readable but the name itself assigned a random GUID.
See also  How to Get PUK Code to Unlock MTN, Airtel, Glo & 9Mobile SIM

         Modifying an Existing Firewall Rule

  • What if you may want to modify a current rule without you removing and also re-forming the rule entirely? To do this, we should run the Set-NetFirewallRule, and then it will allow us in modifying the firewall rule as stated.

$Params = @{         “DisplayName”   = ‘Block WINS’         “Action”        = ‘Allow’} Set-NetFirewallRule @Params

Additional useful capabilities that this Set-NetFirewallRule has are the common ability in which you can operate on multiple rules at one time. This command can be done by finding the rules by one of three parameters.

  • The Name, This is the original placement and if names are on in via the pipeline or a string array then each of it will be acted upon.
  • The DisplayNameSimilar to Name, the multiple pipelined objects or a stringing array will modify all the rules accordingly.
  • The Display Group or Group If the rules are formed and group together; all of those rules grouped can be acted upon at once.

Removing an Existing Firewall Rule

Will you like to extract the existing rule as it may no longer be needed/useful? To carry out this process, you will have to run the command Remove-NetFirewallRule. After you must have run this, it is often wise to use the WhatIf parameter verifying that the rule is the right one to remove.

Remove-NetFirewallRule -DisplayName “Block WINS”

This is very important to note that the command -Remove-NetFirewallRule can remove more than one rule at once.

 

Loading...

Categories: How to

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *