32 lines
1.5 KiB
PowerShell
32 lines
1.5 KiB
PowerShell
[CmdletBinding()]
|
|
param()
|
|
$ErrorActionPreference = 'Stop'
|
|
if ($env:COMPUTERNAME -ine 'SGU-DC02') {
|
|
throw 'Run this site-specific firewall configuration on SGU-DC02.'
|
|
}
|
|
$address = '192.168.54.211'
|
|
if (-not (Get-NetIPAddress -AddressFamily IPv4 -IPAddress $address -ErrorAction SilentlyContinue)) {
|
|
throw 'The CED management-point address is not assigned to this server.'
|
|
}
|
|
$listener = @(Get-NetTCPConnection -LocalPort 10123 -State Listen -ErrorAction SilentlyContinue)
|
|
if (-not $listener.Count) { throw 'The Configuration Manager notification listener is not running.' }
|
|
$program = Join-Path $env:windir 'System32\dllhost.exe'
|
|
foreach ($connection in $listener) {
|
|
if ((Get-Process -Id $connection.OwningProcess).Path -ine $program) {
|
|
throw 'TCP 10123 is owned by an unexpected process; inspect it before opening the firewall.'
|
|
}
|
|
}
|
|
$settings = @{
|
|
Name = 'CED-ConfigMgr-Notification-TCP'
|
|
Direction = 'Inbound'; Action = 'Allow'; Enabled = 'True'; Profile = 'Domain'
|
|
Protocol = 'TCP'; LocalPort = 10123; LocalAddress = $address
|
|
RemoteAddress = '192.168.54.0/24'; Program = $program
|
|
Description = 'Allow CED clients to the Configuration Manager notification server; no public or other-subnet access.'
|
|
}
|
|
if (Get-NetFirewallRule -Name $settings.Name -ErrorAction SilentlyContinue) {
|
|
Set-NetFirewallRule @settings
|
|
} else {
|
|
New-NetFirewallRule @settings -DisplayName 'CED - ConfigMgr client notification TCP 10123' | Out-Null
|
|
}
|
|
Get-NetFirewallRule -Name $settings.Name | Select-Object Name,Enabled,Action,Profile
|