[Requirements]
- For Korean customers implementing E-Tax and VAT module addon, Powershell script setting up port open is beneficial to reduce set up time and eliminate human errors.
[OS]
Windows 10
[Development Language]
PowerShell
[IDE]
PowerShell ISE
[Setting]
#Enable firewall setting
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
[Code]
function Add-FirewallRules {
param(
[Parameter(Mandatory = $true)]
[Array]$Rules
)
foreach ($rule in $Rules) {
$name = $rule.DisplayName
$port = $rule.Port
$direction = $rule.Direction
$ip = $rule.IP
if ($direction -eq "Inbound") {
New-NetFirewallRule `
-DisplayName $name `
-Direction Inbound `
-Protocol TCP `
-LocalPort $port `
-RemoteAddress $ip `
-Action Allow
Write-Host "Created Inbound rule: $name (Port $port, IP $ip)"
}
elseif ($direction -eq "Outbound") {
New-NetFirewallRule `
-DisplayName $name `
-Direction Outbound `
-Protocol TCP `
-RemotePort $port `
-RemoteAddress $ip `
-Action Allow
Write-Host "Created Outbound rule: $name (Port $port, IP $ip)"
}
else {
Write-Host "Invalid direction value: $direction"
}
}
}
# =======================================
# ▶ 실행 예시 (여기에 룰을 원하는 만큼 추가)
# =======================================
$firewallRules = @(
# Port 389 / Outbound
@{
DisplayName = "SmartBill_전자세금계산서_LDAP"
Port = 389
Direction = "Outbound"
IP = @("203.233.91.35", "203.242.205.156", "210.207.195.77", "211.192.169.180", "211.35.96.26")
},
# Port 443 / Outbound
@{
DisplayName = "SmartBill_전자세금계산서_스마트빌"
Port = 443
Direction = "Outbound"
IP = @("183.111.188.142","58.181.27.25")
},
# Port 30000 or 443 / Inbound
@{
DisplayName = "SmartBill_전자세금계산서_스마트빌 개발"
Port = @(443, 30000)
Direction = "Inbound"
IP = @("183.111.188.142", "58.181.27.25")
},
# Port 22 / Outbound
@{
DisplayName = "SmartBill_전자세금계산서_자동업데이트"
Port = 22
Direction = "Outbound"
IP = @("183.111.188.142", "58.181.27.25")
},
# Port 3389 / Inbound
@{
DisplayName = "원격접속"
Port = 3389
Direction = "Outbound"
IP = "58.181.27.16"
}
)
# ▶ 실제 실행
Add-FirewallRules -Rules $firewallRules
[Test]
Ran on my PC and it works well.


[Lesson Learned]
For firewall setting via PowerShell script, enable the related policy and run PowerShell with admin. right
#Enable firewall setting
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
반응형
'ICT' 카테고리의 다른 글
| [SAP B1] Customer Refund Report Query (0) | 2025.11.06 |
|---|---|
| [Automation] SAP Pending Approval Notification (0) | 2025.10.07 |
| [SQL] Basics of SQL Cursor (0) | 2025.04.15 |
| [SQL] Creating a Test Head Blocker (0) | 2025.04.08 |
| [Power Platform] Powerapp Component PCF Push Error in Visual Studio Code (3) | 2024.11.07 |
댓글