جميع التدوينات
Enable SharePoint Ports
SharePoint 2019PowerShellInfrastructure
Setting up a SharePoint 2019 farm means opening the same set of Windows Firewall ports on every server — distributed cache, people picker, service applications, WCF services and the search index. The script below creates all of those rules in one pass, inbound and outbound, using a small reusable function.
function CreateSPPorts($rulName,$dispName,$Desc,$direcT,$portToOpen,$protoCol,$actOn,$prg,$Grp)
{
$params = @{
DisplayName = $dispName
Action = $actOn
Description = $Desc
Direction = $direcT
LocalPort = @($portToOpen)
Name = $rulName
Program = $prg
Profile = 'Any'
Group = $Grp
Protocol = $protoCol
}
Write-Host "Creating Rule for " $rulName " Port " $portToOpen " In/Out Bound " $direcT -ForegroundColor Cyan
New-NetFirewallRule @params
}
Function Main()
{
Import-Module NetSecurity -ErrorAction SilentlyContinue
Write-Host "Creating SharePoint Firewall Ports" -ForegroundColor Cyan
CreateSPPorts "SP 2019 Distributed Cache" "SP 2019 Distributed Cache" "Custom SP 2019 Specific Ports" "Inbound" 22233,22236 "TCP" "Allow" "Any" "Any"
CreateSPPorts "SP 2019 Distributed Cache" "SP 2019 Distributed Cache" "Custom SP 2019 Specific Ports" "Outbound" 22233,22236 "TCP" "Allow" "Any" "Any"
CreateSPPorts "SP 2019 People Picker" "SP 2019 People Picker" "Custom SP 2019 Specific Ports" "Inbound" 53,88,135,137,138,139,389,445,636,749,750,3268,3269 "TCP" "Allow" "Any" "Any"
CreateSPPorts "SP 2019 People Picker" "SP 2019 People Picker" "Custom SP 2019 Specific Ports" "Outbound" 53,88,135,137,138,139,389,445,636,749,750,3268,3269 "TCP" "Allow" "Any" "Any"
CreateSPPorts "SP 2019 Service Applications" "SP 2019 Service Applications" "Custom SP 2019 Specific Ports" "Inbound" 32843,32844 "TCP" "Allow" "Any" "Any"
CreateSPPorts "SP 2019 Service Applications" "SP 2019 Service Applications" "Custom SP 2019 Specific Ports" "Outbound" 32843,32844 "TCP" "Allow" "Any" "Any"
CreateSPPorts "SP 2019 WCF Services" "SP 2019 WCF Services" "Custom SP 2019 Specific Ports" "Inbound" 808 "TCP" "Allow" "Any" "Any"
CreateSPPorts "SP 2019 WCF Services" "SP 2019 WCF Services" "Custom SP 2019 Specific Ports" "Outbound" 808 "TCP" "Allow" "Any" "Any"
New-NetFirewallRule -DisplayName "SP 2019 Search Index Service" -Action Allow -Description "Custom SP 2019 Specific Ports" -Direction Inbound -EdgeTraversalPolicy Allow -LocalPort 16500-16519 -Name "SP 2019 Search Index Service" -Program Any -Protocol TCP
New-NetFirewallRule -DisplayName "SP 2019 Search Index Service" -Action Allow -Description "Custom SP 2019 Specific Ports" -Direction Outbound -EdgeTraversalPolicy Allow -LocalPort 16500-16519 -Name "SP 2019 Search Index Service" -Program Any -Protocol TCP
Write-Host "Completed Creating SharePoint Firewall Ports" -ForegroundColor Green
}
MainRun it in an elevated PowerShell session on each SharePoint server. Adjust the port lists if your topology differs — for example if search components live on dedicated servers.