Community Tutorials Windows Server كيفية تكوين قواعد جدار حماية Windows باستخدام PowerShell
كيفية تكوين قواعد جدار حماية Windows باستخدام PowerShell
WINDOWS SERVER

كيفية تكوين قواعد جدار حماية Windows باستخدام PowerShell

SKYLINE Knowledge Base
Photo by Windows on Unsplash

دليل عملي خطوة بخطوة لـ كيفية تكوين قواعد جدار حماية Windows باستخدام PowerShell. أوامر مختبرة في الإنتاج، متطلبات مسبقة، تحقق نهائي وروابط لمواضيع ذات صلة.

Windows Defender Firewall مدمج في كل تثبيت Windows Server ومفعّل افتراضيًا. الواجهة الرسومية wf.msc مناسبة للتغييرات الفردية؛ PowerShell هو الطريقة الوحيدة العاقلة للتكرار.

المتطلبات المسبقة

  • Windows Server 2019/2022 بحساب administrator.
  • PowerShell كمسؤول.

الخطوة 1: تأكد من تمكين جدار الحماية

Get-NetFirewallProfile | Format-Table Name, Enabled
Set-NetFirewallProfile -Profile Domain,Private,Public -Enabled True

الخطوة 2: السماح بمنفذ (وارد)

New-NetFirewallRule -DisplayName "HTTPS Inbound" `
    -Direction Inbound -Action Allow -Protocol TCP -LocalPort 443 -Profile Any

تقييد RDP بشبكة فرعية:

New-NetFirewallRule -DisplayName "RDP from corp subnet" `
    -Direction Inbound -Action Allow -Protocol TCP -LocalPort 3389 `
    -RemoteAddress 10.0.10.0/24

حظر وجهة صادرة:

New-NetFirewallRule -DisplayName "Block bad" `
    -Direction Outbound -Action Block -RemoteAddress 203.0.113.55/32

الخطوة 3: عرض القواعد

Get-NetFirewallRule | Where-Object Enabled -eq True | Sort-Object Direction
Get-NetFirewallRule -DisplayName "HTTPS Inbound"

الخطوة 4: تعديل قاعدة

Set-NetFirewallRule -DisplayName "HTTPS Inbound" -RemoteAddress 10.0.0.0/8
Disable-NetFirewallRule -DisplayName "HTTPS Inbound"
Enable-NetFirewallRule  -DisplayName "HTTPS Inbound"

الخطوة 5: حذف قاعدة

Remove-NetFirewallRule -DisplayName "HTTPS Inbound"

الخطوة 6: تسجيل جدار الحماية

Set-NetFirewallProfile -Profile Public `
    -LogAllowed True -LogBlocked True `
    -LogFileName "%systemroot%\system32\LogFiles\Firewall\pfirewall.log"

Get-Content "$env:windir\system32\LogFiles\Firewall\pfirewall.log" -Tail 30 -Wait

التحقق

Test-NetConnection www.example.sa -Port 443
Get-NetTCPConnection -State Listen | Sort-Object LocalPort

الخاتمة

قواعد PowerShell قابلة للسكربتة والتحكم بالإصدار وإعادة التطبيق — ثلاث خصائص لا توفرها الواجهة الرسومية.

الخطوات التالية

SKYLINE Engineering

@skyline

The engineering team at SKYLINE Industrial Solutions. We publish field-tested guides drawn from real KSA and GCC deployments.

See author profile
SKYLINE engineering services

Need this implemented for you?

Reading is free — building it right takes a team. SKYLINE engineers ship Windows Server for Aramco vendors, banks, hospitals and government agencies across Saudi Arabia. Talk to us before you start.

Aramco Approved Contractor ISO 9001 · ISO 27001 SAMA CSF aligned NCA ECC ready 247+ KSA clients

Comments

0 total · 0 threads
Be the first to leave a comment.