References > AppInsight Help > AppInsight for Exchange: Create a Firewall Rule

Create a firewall rule

  1. Open PowerShell in the Run as Administrator context.
  2. Create a function for adding firewall rules using the following code:
    function Add-FirewallRule {
    param(
    $name,
    $tcpPorts,
    $appName = $null,
    $serviceName = $null
    )
    $fw = New-Object -ComObject hnetcfg.fwpolicy2
    $rule = New-Object -ComObject HNetCfg.FWRule
    $rule.Name = $name
    if ($appName -ne $null) { $rule.ApplicationName = $appName }
    if ($serviceName -ne $null) { $rule.serviceName = $serviceName }
    $rule.Protocol = 6 #NET_FW_IP_PROTOCOL_TCP
    $rule.LocalPorts = $tcpPorts
    $rule.Enabled = $true
    $rule.Grouping = "@firewallapi.dll,-23255"
    $rule.Profiles = 7 # all
    $rule.Action = 1 # NET_FW_ACTION_ALLOW
    $rule.EdgeTraversal = $false
    $fw.Rules.Add($rule)
    }
  3. Run the function to create the firewall exception for WSMAN using the following command:Add-FirewallRule "Windows Remote Management" "5986" $null $null
  4. Verify the rule was created by navigating to Control Panel > Windows Firewall > Advanced Settings.
  5. Configure AppInsight for Exchange by clicking Configure Server.