$SharePath = "C:\PublicShare" $ShareName = "PUBLIC_SHARE" if(-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { Write-Error "관리자 권한 PowerShell로 실행하세요."; return } if(-not (Test-Path -LiteralPath $SharePath)) { New-Item -ItemType Directory -Path $SharePath -Force | Out-Null } Get-NetConnectionProfile | ForEach-Object { try { if ($_.NetworkCategory -ne 'Private') { Set-NetConnectionProfile -InterfaceIndex $_.InterfaceIndex -NetworkCategory Private -ErrorAction Stop } } catch {} } $displayGroups = @('Network Discovery','File and Printer Sharing','네트워크 검색','파일 및 프린터 공유') Get-NetFirewallRule -ErrorAction SilentlyContinue | Where-Object { $_.DisplayGroup -in $displayGroups } | ForEach-Object { Set-NetFirewallRule -Name $_.Name -Enabled True -Profile Any -ErrorAction SilentlyContinue } $prefixes = @('FPS-','NetworkDiscovery-','FileAndPrinter-') foreach($p in $prefixes) { Get-NetFirewallRule -ErrorAction SilentlyContinue | Where-Object { $_.Name -like "$p*" } | ForEach-Object { Set-NetFirewallRule -Name $_.Name -Enabled True -Profile Any -ErrorAction SilentlyContinue } } 'FDResPub','fdPHost','SSDPSRV','upnphost' | ForEach-Object { try { Set-Service -Name $_ -StartupType Automatic -ErrorAction SilentlyContinue; Start-Service -Name $_ -ErrorAction SilentlyContinue } catch {} } try { Set-SmbServerConfiguration -EnableSMB1Protocol $false -Force -ErrorAction SilentlyContinue | Out-Null Disable-WindowsOptionalFeature -Online -FeatureName "SMB1Protocol" -NoRestart -ErrorAction SilentlyContinue | Out-Null Set-SmbServerConfiguration -EnableSMB2Protocol $true -Force -ErrorAction SilentlyContinue | Out-Null } catch {} New-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Lsa" -Force | Out-Null Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Lsa" -Name "ForceGuest" -Value 1 -Type DWord -Force New-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters" -Force | Out-Null New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters" -Name "AllowInsecureGuestAuth" -PropertyType DWord -Value 1 -Force | Out-Null New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\LanmanWorkstation" -Force | Out-Null New-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\LanmanWorkstation" -Name "AllowInsecureGuestAuth" -PropertyType DWord -Value 1 -Force | Out-Null New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Lsa" -Name "LimitBlankPasswordUse" -PropertyType DWord -Value 0 -Force | Out-Null if (Get-SmbShare -Name $ShareName -ErrorAction SilentlyContinue) { Remove-SmbShare -Name $ShareName -Force -ErrorAction SilentlyContinue; Start-Sleep -Milliseconds 300 } New-SmbShare -Name $ShareName -Path $SharePath -FullAccess "Everyone" -CachingMode None -ErrorAction SilentlyContinue | Out-Null Grant-SmbShareAccess -Name $ShareName -AccountName "Everyone" -AccessRight Full -Force -ErrorAction SilentlyContinue | Out-Null icacls $SharePath /grant "Everyone:(OI)(CI)F" /T | Out-Null try { Restart-Service -Name LanmanServer -Force -ErrorAction SilentlyContinue } catch {} Write-Host "\\$(hostname)\$ShareName 생성됨"