◎ 자동화 스크립트
- 아래 내용을 Notepad에 붙여넣기하고 인코딩을 UTF-8 with BOM으로 변경하고 저장합니다.
# [1. 관리자 권한 확인 및 인코딩]
$OutputEncoding = [System.Text.Encoding]::UTF8
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
Write-Host "`n[권한] 관리자 권한으로 실행 중입니다..." -ForegroundColor Yellow
try {
Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs
} catch {
Write-Host "`n[오류] 관리자 권한 승인이 필요합니다." -ForegroundColor Red
Read-Host "엔터를 누르면 종료합니다."
}
exit
}
# --- [시스템 정보 분석] ---
$verInfo = Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion"
$osName = $verInfo.ProductName
$editionId = $verInfo.EditionID
$buildNumber = [int]$verInfo.CurrentBuild
if ($buildNumber -ge 22000) { $osName = $osName -replace "Windows 10", "Windows 11" }
# Home 에디션 차단
if ($osName -match "Home" -or $editionId -match "Core") {
Write-Host "`n=================================================" -ForegroundColor Red
Write-Host " [차단] 현재 시스템은 $osName 에디션입니다."
Write-Host " RDP 서버 기능은 Pro / Enterprise에서만 지원됩니다."
Write-Host "=================================================" -ForegroundColor Red
Read-Host " 엔터를 누르면 종료합니다."
exit
}
# --- [함수: RDP 보안 제어] ---
function Set-RDP {
param([string]$Action)
switch ($Action) {
"On" {
Write-Host "`n[작업] 원격 데스크톱(RDP) 기능을 활성화합니다..." -ForegroundColor Cyan
Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -Name "fDenyTSConnections" -Value 0
Enable-NetFirewallRule -DisplayGroup "@FirewallAPI.dll,-28752" -ErrorAction SilentlyContinue # 원격 데스크톱 규칙
# NLA 강제 설정 (V2.5 기준 유지)
Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -Name "UserAuthentication" -Value 1
Write-Host "[알림] 설정 적용을 위해 서비스를 재시작합니다..." -ForegroundColor Gray
Restart-Service -Name TermService -Force
Write-Host "[완료] RDP 기능이 켜졌습니다. (NLA 보안 적용)" -ForegroundColor Green
}
"SecurePort" {
Write-Host "`n[보안강화] RDP 포트 변경을 시작합니다..." -ForegroundColor Cyan
$regPath = 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp'
$currentPort = (Get-ItemProperty -Path $regPath).PortNumber
Write-Host " 현재 설정된 포트: $currentPort" -ForegroundColor Gray
$newPort = Read-Host " 변경할 포트 번호 입력 (예: 33890)"
if (-not $newPort) { Write-Host " 취소되었습니다."; return }
# 1. 레지스트리 포트 변경
Set-ItemProperty -Path $regPath -Name "PortNumber" -Value $newPort
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\VideoConfig' -Name "PortNumber" -Value $newPort -ErrorAction SilentlyContinue
# 2. 방화벽 설정 업데이트
Write-Host "[방화벽] 기존 사용자 지정 규칙 정리 및 $newPort 포트 등록 중..." -ForegroundColor Yellow
Remove-NetFirewallRule -DisplayName "RDP_Custom_Port" -ErrorAction SilentlyContinue
New-NetFirewallRule -DisplayName "RDP_Custom_Port" -Direction Inbound -Action Allow -Protocol TCP -LocalPort $newPort | Out-Null
# 3. 서비스 즉시 재시작 (V2.5에 추가된 로직)
Write-Host "[서비스] 변경된 포트를 즉시 적용하기 위해 RDP 서비스를 재시작합니다..." -ForegroundColor Cyan
Write-Host " (원격 접속 중인 경우 연결이 일시적으로 끊어집니다.)" -ForegroundColor Yellow
Restart-Service -Name TermService -Force
Write-Host "`n[완료] 포트가 $newPort (으)로 변경 및 즉시 적용되었습니다." -ForegroundColor Green
}
"Off" {
Write-Host "`n[작업] 원격 데스크톱 기능을 비활성화합니다..." -ForegroundColor Yellow
Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -Name "fDenyTSConnections" -Value 1
Restart-Service -Name TermService -Force
Write-Host "[완료] RDP 기능이 꺼졌습니다." -ForegroundColor Green
}
}
Read-Host "`n엔터를 누르면 메뉴로 돌아갑니다."
}
# --- [메인 메뉴] ---
while ($true) {
Clear-Host
Write-Host "=================================================" -ForegroundColor White
Write-Host " 원격 데스크톱(RDP) 보안 관리 도구 " -ForegroundColor Cyan
Write-Host "================================================="
Write-Host " [OS 정보] $osName ($editionId)" -ForegroundColor Yellow
Write-Host " [빌드번호] $buildNumber" -ForegroundColor Gray
Write-Host "-------------------------------------------------"
Write-Host " 1. [켜기] 원격 데스크톱 활성화 (NLA 적용)"
Write-Host " 2. [보안강화] RDP 포트 변경 및 즉시 적용" -ForegroundColor Green
Write-Host " 3. [끄기] 원격 데스크톱 비활성화" -ForegroundColor Yellow
Write-Host " 4. [재부팅] 시스템 즉시 재부팅" -ForegroundColor Red
Write-Host " 0. 종료"
Write-Host "================================================="
$sel = Read-Host "선택"
switch ($sel) {
"1" { Set-RDP -Action "On" }
"2" { Set-RDP -Action "SecurePort" }
"3" { Set-RDP -Action "Off" }
"4" { Restart-Computer }
"0" { exit }
}
}
- powershell을 실행하고 파일이 만들어진 폴더로 이동하고 아래 명령어를 실행합니다.
| PS C:\Users\Users\Downloads> powershell -ExecutionPolicy Bypass -File .\RDP_Manager.ps1 |
[원격 데스크톱 연결 설정]
1. 연결하려는 PC를 원격 연결이 허용되도록 설정하려면 다음과 같이 하세요.
◎ 파일 탐색기 -> 내 PC(마우스 오른쪽) -> 속성 -> 원격 데스크톱 -> 켬





또는
◎ 시작(마우스 오른쪽) -> 설정 -> 원격 데스크톱 -> 켬





[원격 데스크톱 포트 변경 방법]
◎ 레지스트리를 수정하여 Windows 컴퓨터에서 해당 수신 포트를 변경할 수 있습니다.
1. 레지스트리 편집기를 시작합니다. (window 키 + R -> 실행 -> regedit)

2. 다음 레지스트리 하위 키로 이동합니다.
컴퓨터\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp

3. PortNumber를 찾습니다.
PortNumber 더블클릭, 10진수 선택
4. 새 포트 번호를 입력하고 확인을 클릭합니다.

[윈도우 방화벽 설정 변경]
방화벽을 사용하는 경우 새 포트 번호로의 연결을 허용하도록 방화벽을 구성해야 합니다.
◎ window 키 + R -> 실행 -> wf.msc

또는
◎ window 키(마우스 오른쪽) -> 설정 검색-> 방화벽




1. 새 수신 포트에 대해 인바운드 규칙 선택한 다음 새 규칙 을 선택합니다.

2. 새 인바운드 규칙 마법사 에서 포트 를 선택한 후 다음 을 선택합니다.

3. 프로토콜은 TCP 를 선택하고, 특정 로컬 포트에 원하는 포트 번호를 입력하고 다음 을 선택합니다.

4. 연결 허용 을 선택한 후 다음 을 선택합니다.

5. 원격 연결을 위한 네트워크 종류를 포함해 사용할 네트워크 유형을 하나 이상 선택하고 다음 을 선택합니다.

6. 규칙의 이름(예: 원격 데스크톱)을 추가하고 마침을 선택합니다.

7. 새 규칙이 인바운드 규칙 목록에서 표시되어 선택되어 있어야 합니다.

[원격 데스크톱 연결 방법]
원격 데스크톱을 사용하여, 설정한 PC에 연결합니다.
◎ window 키 + R -> 실행 -> mstsc

1. 원격 데스크톱을 사용하여 접속할 PC의 IP와 PORT 번호를 입력합니다.(예: 192.168.0.1:9999)

2. 원격 데스크톱 연결 화면에서 연결을 선택합니다.

3. 사용자 자격 증명 입력화면에서 사용자 이름과 암호를 입력하고 확인을 선택합니다.

4. 원격 데스크톱 연결 화면에서 예를 선택합니다.

'IT > Windows' 카테고리의 다른 글
| [Windows] WSL 2.6.0: 마이크로소프트의 최초 오픈소스 릴리즈 (3) | 2025.06.24 |
|---|---|
| [Windows] 외장하드디스크(USB HDD) 절전모드 해제 (0) | 2023.01.09 |
| [Windows] 윈도우 11 사용자 계정 이름 및 사용자 폴더명 바꾸기 (85) | 2021.10.11 |
| [Windows] 윈도우 11 로컬계정으로 설치하기(클린설치) (0) | 2021.10.10 |
| [Windows] 윈도우 11 지원 시스템 최소 사양 (0) | 2021.10.10 |
