# Windows 보안 설정을 PowerShell로 점검하고 고친 뒤 다시 확인하기

> Windows 11에서 방화벽, SMB, 원격 데스크톱 등 14개 항목을 읽기 전용 스크립트로 점검하고, 계획 미리보기를 거쳐 설정을 고친 뒤 재점검으로 PASS 7에서 PASS 12가 된 것을 Windows 보안 앱 화면과 함께 확인합니다.

- 주소: https://copyandrun.com/blog/windows-security-baseline-harden-recheck/
- 분야: Windows 보안
- 발행일: 2026-10-27
- 태그: Windows, PowerShell, 보안 점검

Windows 보안 설정이 기준에 맞는지 확인하는 일은 한 번 점검하고 끝나지 않습니다. 틀린 곳을 찾고, 고치고, 고쳐졌는지 다시 확인해야 점검이 완성됩니다. 이 글에서는 PowerShell 스크립트 두 개로 그 순서를 한 번에 해 봅니다. 첫 번째 스크립트가 Defender, 방화벽, SMB, 원격 데스크톱 등 14개 항목을 읽어 PASS, WARN, FAIL로 판정하고, 두 번째 스크립트가 FAIL과 WARN 가운데 안전하게 고칠 수 있는 항목을 바로잡습니다. 마지막으로 첫 번째 스크립트를 다시 돌려 결과가 바뀌었는지 확인합니다.

이 실습에는 점검 항목이 실제로 잡히는지 보려고 방화벽, 원격 데스크톱, SMB 서명, Guest 계정을 일부러 약하게 만드는 단계가 있습니다. 해당 단계는 점검 항목을 확인하는 용도이므로 업무용 PC에서는 건너뛰고 점검과 계획 확인만 진행합니다. 약하게 만든 설정은 6단계의 Harden 스크립트로 되돌립니다.

## 준비물

| 항목 | 확인한 값 |
|---|---|
| 운영체제 | Windows 11, 표시 언어 한국어 |
| PowerShell | 관리자 PowerShell (Windows PowerShell 5.1) |

## 1. 점검 스크립트 준비하기

`Check-WindowsSecurity.ps1`은 값만 읽습니다. `Get-` 명령과 레지스트리 읽기만 쓰고 설정을 바꾸는 명령은 없습니다. 항목 하나가 실패해도 나머지는 계속 점검합니다. 문구는 영문으로만 썼습니다. Windows PowerShell 5.1은 BOM이 없는 파일의 한글을 깨뜨리기 때문입니다.

```powershell
# Read-only Windows security baseline check. It changes nothing.
# Usage: powershell -NoProfile -ExecutionPolicy Bypass -File .\Check-WindowsSecurity.ps1
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
$results = New-Object System.Collections.Generic.List[object]

function Add-Result($Item, $Value, $Status, $Advice) {
    if ($Status -eq "PASS") { $Advice = "-" }
    $results.Add([pscustomobject]@{ Item = $Item; Value = "$Value"; Status = $Status; Advice = $Advice })
}

function Test-Check($Item, [scriptblock]$Block) {
    try { & $Block }
    catch { Add-Result $Item "unreadable" "WARN" "Run in an elevated PowerShell, or this feature is not available." }
}

Test-Check "Defender real-time protection" {
    $mp = Get-MpComputerStatus
    $s = if ($mp.RealTimeProtectionEnabled) { "PASS" } else { "FAIL" }
    Add-Result "Defender real-time protection" $mp.RealTimeProtectionEnabled $s "Turn on real-time protection in Windows Security."
    $age = [int]((Get-Date) - $mp.AntivirusSignatureLastUpdated).TotalDays
    $s = if ($age -le 3) { "PASS" } elseif ($age -le 7) { "WARN" } else { "FAIL" }
    Add-Result "Defender signature age (days)" $age $s "Update signatures: Windows Security > Virus & threat protection updates."
    $s = if ($mp.IsTamperProtected) { "PASS" } else { "WARN" }
    Add-Result "Defender tamper protection" $mp.IsTamperProtected $s "Turn on tamper protection so malware cannot disable Defender."
}

Test-Check "Firewall" {
    foreach ($p in Get-NetFirewallProfile) {
        $s = if ($p.Enabled) { "PASS" } else { "FAIL" }
        Add-Result ("Firewall " + $p.Name + " profile") $p.Enabled $s "Turn the profile on unless another firewall product manages it."
    }
}

Test-Check "UAC" {
    $v = (Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System").EnableLUA
    $s = if ($v -eq 1) { "PASS" } else { "FAIL" }
    Add-Result "UAC (EnableLUA)" $v $s "Set EnableLUA to 1 and reboot."
}

Test-Check "SMB" {
    $smb = Get-SmbServerConfiguration
    $s = if (-not $smb.EnableSMB1Protocol) { "PASS" } else { "FAIL" }
    Add-Result "SMBv1 server" $smb.EnableSMB1Protocol $s "Disable SMBv1. It is the protocol abused by worms such as WannaCry."
    $s = if ($smb.RequireSecuritySignature) { "PASS" } else { "WARN" }
    Add-Result "SMB signing required" $smb.RequireSecuritySignature $s "Require SMB signing to block relay attacks."
}

Test-Check "BitLocker" {
    $vol = Get-BitLockerVolume -MountPoint $env:SystemDrive
    $s = if ($vol.ProtectionStatus -eq "On") { "PASS" } else { "WARN" }
    Add-Result ("BitLocker " + $vol.MountPoint) $vol.ProtectionStatus $s "Encrypt the system drive if the device can be lost or stolen."
}

Test-Check "RDP" {
    $v = (Get-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server").fDenyTSConnections
    $on = ($v -eq 0)
    $s = if ($on) { "WARN" } else { "PASS" }
    Add-Result "Remote Desktop enabled" $on $s "Turn off Remote Desktop unless needed. If needed, require NLA and restrict the source."
}

Test-Check "Secure Boot" {
    $sb = Confirm-SecureBootUEFI
    $s = if ($sb) { "PASS" } else { "WARN" }
    Add-Result "Secure Boot" $sb $s "Enable Secure Boot in UEFI settings."
}

Test-Check "Guest account" {
    $g = Get-LocalUser | Where-Object { $_.SID.Value -like "*-501" }
    $s = if (-not $g.Enabled) { "PASS" } else { "FAIL" }
    Add-Result "Guest account enabled" $g.Enabled $s "Disable the built-in Guest account."
}

Test-Check "AutoLogon" {
    $v = (Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon").AutoAdminLogon
    $on = ($v -eq "1")
    $s = if ($on) { "FAIL" } else { "PASS" }
    Add-Result "Automatic sign-in" $on $s "Turn off automatic sign-in. It stores credentials on the machine."
}

$results | Format-Table Item, Value, Status -AutoSize

$count = $results | Group-Object Status | ForEach-Object { $_.Name + "=" + $_.Count }
Write-Output ("Summary: " + ($count -join "  "))
```

판정 기준은 두 갈래입니다. 반드시 켜야 하는 항목(방화벽, UAC, SMBv1 끄기, Guest 끄기, 자동 로그인 끄기, Defender 실시간 보호)이 어긋나면 FAIL입니다. 환경에 따라 달라질 수 있는 항목(BitLocker, 원격 데스크톱, Secure Boot, SMB 서명)은 WARN입니다.

## 2. 처음 상태 점검하기

먼저 현재 상태를 점검합니다. 관리자 PowerShell에서 실행합니다.

```powershell
powershell -NoProfile -ExecutionPolicy Bypass -File .\Check-WindowsSecurity.ps1
```

```
# 기대 출력 (일부)
Defender signature age (days) 405   FAIL
Firewall Domain profile       True  PASS
Firewall Private profile      True  PASS
Firewall Public profile       True  PASS
BitLocker C:                  Off   WARN
Remote Desktop enabled        False PASS
Guest account enabled         False PASS

Summary: PASS=12  FAIL=1  WARN=1
```

기본 설정의 Windows 11은 대부분 항목이 안전해서 FAIL이 하나뿐입니다. Defender 서명이 405일 전 것이라는 항목이며, 서명을 갱신하기 전에는 3단계 이후에도 그대로 남습니다.

## 3. 설정을 일부러 약하게 만들기

고치는 과정을 보려면 고칠 것이 있어야 합니다. `Set-InsecureBaseline.ps1`로 네 가지를 약하게 만듭니다. 방화벽 Private과 Public 프로필 끄기, 원격 데스크톱 켜기, SMB 서명 요구 끄기, Guest 계정 켜기입니다.

```powershell
# Weakens four settings on purpose so the check has something to find.
# Run in an elevated PowerShell, then restore with Harden-WindowsSecurity.ps1 -Apply.
Set-NetFirewallProfile -Profile Private, Public -Enabled False
Set-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server" -Name fDenyTSConnections -Value 0
Set-SmbServerConfiguration -RequireSecuritySignature $false -Force
Enable-LocalUser -Name Guest
Write-Output "Settings weakened: firewall (Private, Public) off, RDP on, SMB signing off, Guest on"
```

```powershell
powershell -NoProfile -ExecutionPolicy Bypass -File .\Set-InsecureBaseline.ps1
powershell -NoProfile -ExecutionPolicy Bypass -File .\Check-WindowsSecurity.ps1
```

```
# 기대 출력
Settings weakened: firewall (Private, Public) off, RDP on, SMB signing off, Guest on
```

![방화벽 Private과 Public, Guest 계정이 FAIL이고 SMB 서명과 원격 데스크톱과 BitLocker가 WARN으로 나와 PASS 7, FAIL 4, WARN 3으로 요약된 PowerShell 화면](https://copyandrun.com/img/windows-security-baseline-harden-recheck/01-check-before.png)

이제 PASS 7, FAIL 4, WARN 3입니다. 스크립트가 지적한 원격 데스크톱, SMB 서명, Guest 계정을 Windows 기본 화면에서도 확인합니다. 먼저 시스템 속성의 원격 탭입니다.

![시스템 속성 원격 탭에서 이 컴퓨터에 대한 원격 연결 허용이 선택된 모습](https://copyandrun.com/img/windows-security-baseline-harden-recheck/02-rdp-before.png)

다음은 로컬 보안 정책의 보안 옵션입니다. `Microsoft 네트워크 서버: 디지털 서명 통신(항상)` 항목이 사용 안 함으로 표시됩니다. 기본 제공 관리자 계정 이름은 가렸습니다.

![로컬 보안 정책의 보안 옵션에서 Microsoft 네트워크 서버: 디지털 서명 통신(항상) 항목이 사용 안 함으로 표시된 모습](https://copyandrun.com/img/windows-security-baseline-harden-recheck/09-smb-before.png)

마지막으로 로컬 사용자 및 그룹에서 Guest 속성을 열면 계정 사용 안 함 확인란이 비어 있습니다.

![Guest 속성의 일반 탭에서 계정 사용 안 함 확인란이 선택되지 않은 모습](https://copyandrun.com/img/windows-security-baseline-harden-recheck/11-guest-before.png)

## 4. Windows 보안 앱 화면과 대조하기

스크립트 판정이 맞는지 Windows 보안 앱으로 확인합니다. 방화벽 및 네트워크 보호 화면에 "Microsoft Defender 방화벽이 장치에 위험할 수 있는 설정을 사용하고 있습니다."라는 경고가 뜨고, 도메인 네트워크는 `방화벽이 켜져 있습니다.`, 개인 네트워크는 `방화벽이 꺼져 있습니다.`로 나옵니다.

![Windows 보안의 방화벽 및 네트워크 보호 화면에서 안전하지 않을 수 있는 설정이라는 경고와 함께 도메인 네트워크는 켜짐, 개인 네트워크는 꺼짐으로 표시된 모습](https://copyandrun.com/img/windows-security-baseline-harden-recheck/07-firewall-before.png)

스크립트의 Private 프로필 `False`와 같은 결과입니다. 이 화면에는 공용 네트워크 항목이 잘려 보이지 않아, Public 프로필은 스크립트의 결과로만 확인했습니다.

## 5. 고치기 전에 계획부터 보기

`Harden-WindowsSecurity.ps1`은 기본 실행에서는 아무것도 바꾸지 않고 하려는 일을 목록으로만 보여 줍니다. `-Apply`를 붙여야 실제로 바꿉니다. 점검 결과를 보고 곧바로 고치다가 업무에 필요한 설정까지 꺼 버리는 사고를 막기 위한 장치입니다.

```powershell
# Fixes the settings that Check-WindowsSecurity.ps1 reports as FAIL or WARN.
# Without -Apply it only prints what it would change. With -Apply it changes the settings.
# Run in an elevated PowerShell. Read the plan output before using -Apply.
param([switch]$Apply)

[Console]::OutputEncoding = [System.Text.Encoding]::UTF8

function Step($Text, [scriptblock]$Do) {
    if ($Apply) {
        try { & $Do; Write-Output ("DONE    " + $Text) }
        catch { Write-Output ("FAILED  " + $Text + " : " + $_.Exception.Message) }
    } else {
        Write-Output ("PLAN    " + $Text)
    }
}

Step "Turn on Windows Firewall for Domain, Private, Public" {
    Set-NetFirewallProfile -Profile Domain, Private, Public -Enabled True
}
Step "Turn off Remote Desktop" {
    Set-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server" -Name fDenyTSConnections -Value 1
}
Step "Disable SMBv1 server" {
    Set-SmbServerConfiguration -EnableSMB1Protocol $false -Force
}
Step "Require SMB signing" {
    Set-SmbServerConfiguration -RequireSecuritySignature $true -Force
}
Step "Disable the built-in Guest account" {
    Disable-LocalUser -Name Guest
}
Step "Turn off automatic sign-in" {
    Set-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name AutoAdminLogon -Value "0"
}

if (-not $Apply) { Write-Output "Nothing changed. Run again with -Apply to make these changes." }
```

```powershell
powershell -NoProfile -ExecutionPolicy Bypass -File .\Harden-WindowsSecurity.ps1
```

```
# 기대 출력
PLAN    Turn on Windows Firewall for Domain, Private, Public
PLAN    Turn off Remote Desktop
PLAN    Disable SMBv1 server
PLAN    Require SMB signing
PLAN    Disable the built-in Guest account
PLAN    Turn off automatic sign-in
Nothing changed. Run again with -Apply to make these changes.
```

![Harden 스크립트를 인자 없이 실행하자 여섯 가지 변경 계획이 PLAN으로 나열되고 아무것도 바뀌지 않았다는 문구가 나온 PowerShell 화면](https://copyandrun.com/img/windows-security-baseline-harden-recheck/03-harden-plan.png)

계획에는 이미 안전한 항목(SMBv1, 자동 로그인)도 들어 있습니다. 안전한 값으로 다시 설정해도 결과는 같으므로 그대로 두었습니다.

## 6. 적용하고 다시 점검하기

```powershell
powershell -NoProfile -ExecutionPolicy Bypass -File .\Harden-WindowsSecurity.ps1 -Apply
```

```
# 기대 출력
DONE    Turn on Windows Firewall for Domain, Private, Public
DONE    Turn off Remote Desktop
DONE    Disable SMBv1 server
DONE    Require SMB signing
DONE    Disable the built-in Guest account
DONE    Turn off automatic sign-in
```

![Harden 스크립트에 Apply를 붙여 실행하자 여섯 항목이 모두 DONE으로 표시된 PowerShell 화면](https://copyandrun.com/img/windows-security-baseline-harden-recheck/04-harden-apply.png)

각 항목은 따로 `try/catch`로 감싸서, 하나가 실패해도 나머지를 계속 적용하고 실패한 줄에는 `FAILED`와 이유를 적도록 했습니다. 이번에는 여섯 개가 모두 성공했습니다.

같은 점검 스크립트를 다시 돌립니다.

```powershell
powershell -NoProfile -ExecutionPolicy Bypass -File .\Check-WindowsSecurity.ps1
```

```
# 기대 출력 (일부)
Firewall Private profile      True  PASS
Firewall Public profile       True  PASS
SMB signing required          True  PASS
Remote Desktop enabled        False PASS
Guest account enabled         False PASS

Summary: PASS=12  FAIL=1  WARN=1
```

![재점검에서 방화벽, SMB 서명, 원격 데스크톱, Guest 계정이 모두 PASS로 바뀌어 PASS 12, FAIL 1, WARN 1로 요약된 PowerShell 화면](https://copyandrun.com/img/windows-security-baseline-harden-recheck/05-check-after.png)

FAIL 4개 가운데 3개와 WARN 3개 가운데 2개가 PASS로 돌아와, 3단계 직후의 PASS 7에서 PASS 12가 되었습니다. 남은 것은 Defender 서명과 BitLocker 두 항목뿐입니다. 같은 기본 화면 세 곳에서도 값이 바뀌었습니다. 시스템 속성의 원격 탭은 원격 연결 허용 안 함으로 돌아왔습니다.

![시스템 속성 원격 탭에서 이 컴퓨터에 대한 원격 연결 허용 안 함이 선택된 모습](https://copyandrun.com/img/windows-security-baseline-harden-recheck/06-rdp-after.png)

로컬 보안 정책에서는 서명 항목이 사용으로 바뀌었습니다.

![로컬 보안 정책의 보안 옵션에서 Microsoft 네트워크 서버: 디지털 서명 통신(항상) 항목이 사용으로 표시된 모습](https://copyandrun.com/img/windows-security-baseline-harden-recheck/10-smb-after.png)

Guest 속성에서는 계정 사용 안 함 확인란이 선택되었습니다.

![Guest 속성의 일반 탭에서 계정 사용 안 함 확인란이 선택된 모습](https://copyandrun.com/img/windows-security-baseline-harden-recheck/12-guest-after.png)

Windows 보안 앱에서도 도메인, 개인, 공용 세 네트워크가 모두 `방화벽이 켜져 있습니다.`로 바뀌었고, 앞서 보인 경고는 사라졌습니다.

![Windows 보안의 방화벽 및 네트워크 보호 화면에서 도메인, 개인, 공용 세 네트워크가 모두 켜짐으로 표시된 모습](https://copyandrun.com/img/windows-security-baseline-harden-recheck/08-firewall-after.png)

## 7. 고치지 않은 두 항목

| 항목 | 남은 이유 |
|---|---|
| Defender 서명 405일 (FAIL) | 이 스크립트는 서명을 갱신하지 않습니다. Windows 보안의 보호 업데이트나 Windows Update로 갱신하면 해결됩니다 |
| BitLocker 꺼짐 (WARN) | 스크립트에 넣지 않았습니다. 암호화를 켜면 복구 키를 저장하고 재부팅하는 절차가 따라와서, 자동으로 바꾸기에는 위험이 큽니다 |

점검 스크립트의 판단이 맞다고 해서 항상 자동으로 고쳐야 하는 것은 아닙니다. 이 글의 Harden 스크립트는 되돌리기 쉽고 부작용이 적은 설정만 다룹니다.

## 자주 막히는 곳

| 증상 | 원인과 해결 |
|---|---|
| 스크립트를 실행할 수 없다는 오류가 납니다 | 실행 정책 때문입니다. 글의 명령처럼 `-ExecutionPolicy Bypass -File`로 한 번만 우회해서 실행합니다 |
| 일부 항목이 `unreadable`로 나옵니다 | 관리자 권한이 아니거나 해당 기능이 없는 환경입니다. 관리자 PowerShell에서 다시 실행합니다 |
| Apply 뒤에도 FAIL이 남습니다 | 그룹 정책이나 보안 제품이 값을 덮어쓸 수 있습니다. `FAILED` 줄의 이유와 정책 위치를 먼저 확인합니다 |
| 원격 데스크톱을 껐더니 접속이 끊깁니다 | 원격으로 작업 중이라면 끄기 전에 다른 연결 방법을 준비합니다. 로컬 콘솔이나 다른 관리 도구로 접속할 수 있는지 먼저 확인합니다 |
| 로그인했는데 다른 사용자가 로그인 중이라고 합니다 | 원격 명령 세션이 사용자 세션으로 남은 것입니다. `quser`로 세션을 보고 `logoff 세션번호`로 정리합니다 |

## 이어서 해 볼 것

- **BitLocker 추가**: TPM이 있는 PC에서 암호화를 켜고 복구 키를 따로 보관하는 절차를 해 봅니다.
- **정기 점검**: 작업 스케줄러에 점검 스크립트를 등록하고 매주 보고서를 비교합니다.
- **다음 글**: 이벤트 로그에서 로그온 실패를 분석하는 글로 이어집니다. 원격 로그온 실패를 직접 만들어 볼 수 있습니다.

## 확인 범위

- **해 본 것:** 2026-10-27, Windows 11의 Windows PowerShell 5.1에서 직접 실행했습니다. 처음 상태 점검, 설정을 약하게 만든 뒤의 점검, Harden의 계획과 적용, 재점검, Windows 보안 앱의 방화벽 화면, 시스템 속성, 로컬 보안 정책, Guest 속성 화면은 모두 실행 결과입니다. 화면은 2026-10-28에 표시 언어를 한국어로 하여 촬영했습니다. 점검 스크립트의 판정과 이 화면들은 방화벽, 원격 데스크톱, SMB 서명, Guest 항목에서 일치했습니다.
- **해 보지 않은 것:** Defender 서명 갱신, BitLocker 설정, 도메인에 가입된 PC, Windows 10과 Windows Server, 일반 사용자 권한에서의 동작.
- **읽을 때 주의:** Defender 서명 경과 일수는 촬영일이 달라 407일로 나옵니다. 도메인 PC에서는 그룹 정책이 값을 다시 덮어쓸 수 있습니다. 판정 기준은 이 글이 정한 간단한 기준이며 CIS Benchmark 같은 공식 점검 기준을 대체하지 않습니다. 적용 전에 계획 출력을 읽고 영향을 확인합니다. 방화벽을 켜면 허용되던 인바운드 연결이 막히고, 원격 데스크톱을 끄면 원격 접속이 끊기며, SMB 서명을 요구하면 서명을 지원하지 않는 오래된 클라이언트의 접속이 거부될 수 있습니다. 되돌리려면 해당 설정을 이전 값으로 직접 바꿉니다.
