| # ============================================================ | |
| # REMOVE ALL EXTERNAL BLOCK RULES - Restore Network | |
| # ลบกฎบล็อกทั้งหมด คืนค่าการเชื่อมต่ออินเทอร์เน็ต | |
| # ============================================================ | |
| $isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) | |
| if (-not $isAdmin) { | |
| Write-Host "[ERROR] Run as Administrator!" -ForegroundColor Red | |
| exit 1 | |
| } | |
| Write-Host "`n========================================" -ForegroundColor Green | |
| Write-Host " REMOVING ALL BLOCK RULES" -ForegroundColor Green | |
| Write-Host "========================================`n" -ForegroundColor Green | |
| # 1. RESET FIREWALL TO DEFAULT | |
| Write-Host "[1] Resetting Firewall to DEFAULT..." -ForegroundColor Yellow | |
| netsh advfirewall reset | Out-Null | |
| Write-Host " [OK] Firewall reset to default" -ForegroundColor Green | |
| # 2. REMOVE SPECIFIC BLOCK RULES | |
| Write-Host "`n[2] Removing specific block rules..." -ForegroundColor Yellow | |
| $rulesToRemove = @( | |
| "Allow-Localhost-Loopback", | |
| "Allow-Localhost-Loopback-v6", | |
| "Block-External-*", | |
| "Block-DNS-Outbound", | |
| "Block-DNS-Outbound-TCP", | |
| "Block-Port-*-Out", | |
| "Block-ICMPv4", | |
| "Block-ICMPv6", | |
| "Allow-LAN-*" | |
| ) | |
| foreach ($rule in $rulesToRemove) { | |
| $found = Get-NetFirewallRule -DisplayName $rule -ErrorAction SilentlyContinue | |
| if ($found) { | |
| Remove-NetFirewallRule -DisplayName $rule -ErrorAction SilentlyContinue | |
| Write-Host " [OK] Removed: $rule" -ForegroundColor Green | |
| } | |
| } | |
| # 3. RESTORE FIREWALL PROFILE DEFAULTS | |
| Write-Host "`n[3] Restoring firewall profile defaults..." -ForegroundColor Yellow | |
| Set-NetFirewallProfile -Profile Domain,Public,Private ` | |
| -Enabled True ` | |
| -DefaultInboundAction Block ` | |
| -DefaultOutboundAction Allow ` | |
| -AllowUnicastResponseToMulticast True ` | |
| -AllowInboundRules True ` | |
| -AllowOutboundRules True ` | |
| -AllowLocalFirewallRules True ` | |
| -AllowLocalIPsecRules True | |
| Write-Host " [OK] Inbound = Block (default)" -ForegroundColor Green | |
| Write-Host " [OK] Outbound = Allow (default)" -ForegroundColor Green | |
| # 4. RESTORE WINDOWS UPDATE | |
| Write-Host "`n[4] Restoring Windows Update..." -ForegroundColor Yellow | |
| $wuaPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" | |
| if (Test-Path $wuaPath) { | |
| Remove-Item -Path $wuaPath -Force -ErrorAction SilentlyContinue | |
| Write-Host " [OK] Windows Update policy removed" -ForegroundColor Green | |
| } | |
| # 5. RESTORE ONEDRIVE | |
| Write-Host "`n[5] Restoring OneDrive..." -ForegroundColor Yellow | |
| $cloudPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\OneDrive" | |
| if (Test-Path $cloudPath) { | |
| Remove-Item -Path $cloudPath -Force -ErrorAction SilentlyContinue | |
| Write-Host " [OK] OneDrive policy removed" -ForegroundColor Green | |
| } | |
| # 6. CLEAN HOSTS FILE (remove telemetry blocks) | |
| Write-Host "`n[6] Cleaning hosts file..." -ForegroundColor Yellow | |
| $hostsPath = "C:\Windows\System32\drivers\etc\hosts" | |
| $hostsContent = Get-Content $hostsPath -ErrorAction SilentlyContinue | |
| $telemetryDomains = @( | |
| "vortex.data.microsoft.com", | |
| "vortex-win.data.microsoft.com", | |
| "telecommand.telemetry.microsoft.com", | |
| "oca.telemetry.microsoft.com", | |
| "sqm.telemetry.microsoft.com", | |
| "watson.telemetry.microsoft.com", | |
| "redir.metaservices.microsoft.com", | |
| "settings-sandbox.data.microsoft.com", | |
| "telemetry.appex.bing.net", | |
| "telemetry.urs.microsoft.com", | |
| "schemas.microsoft.com", | |
| "statsfe2.ws.microsoft.com", | |
| "corpext.msitadfs.glbdns2.microsoft.com", | |
| "compatexchange.cloudapp.net", | |
| "cs1.wpc.v0cdn.net", | |
| "a-0001.a-msedge.net", | |
| "a-0002.a-msedge.net", | |
| "diagnostics.support.microsoft.com", | |
| "corp.sts.microsoft.com", | |
| "statsfe1.ws.microsoft.com", | |
| "pre.footprintpredict.com", | |
| "i1.services.social.microsoft.com", | |
| "feedback.windows.com", | |
| "feedback.microsoft-hohm.com", | |
| "feedback.search.microsoft.com" | |
| ) | |
| $cleaned = $hostsContent | Where-Object { | |
| $line = $_ | |
| $isTelemetry = $false | |
| foreach ($domain in $telemetryDomains) { | |
| if ($line -match $domain) { | |
| $isTelemetry = $true | |
| break | |
| } | |
| } | |
| return -not $isTelemetry | |
| } | |
| $cleaned | Set-Content -Path $hostsPath -Force | |
| Write-Host " [OK] Telemetry entries removed from hosts file" -ForegroundColor Green | |
| # 7. ENABLE NETWORK ADAPTERS | |
| Write-Host "`n[7] Ensuring network adapters are enabled..." -ForegroundColor Yellow | |
| $disabledAdapters = Get-NetAdapter | Where-Object { $_.Status -ne "Up" -and $_.Name -notmatch "Loopback" } | |
| foreach ($adapter in $disabledAdapters) { | |
| Enable-NetAdapter -Name $adapter.Name -Confirm:$false -ErrorAction SilentlyContinue | |
| Write-Host " [OK] Enabled: $($adapter.Name)" -ForegroundColor Green | |
| } | |
| # 8. RESTORE USB STORAGE (if previously blocked) | |
| Write-Host "`n[8] Restoring USB Storage access..." -ForegroundColor Yellow | |
| $usbPath = "HKLM:\SYSTEM\CurrentControlSet\Services\USBSTOR" | |
| if (Test-Path $usbPath) { | |
| Set-ItemProperty -Path $usbPath -Name "Start" -Value 3 -Force | |
| Write-Host " [OK] USBSTOR restored (value=3)" -ForegroundColor Green | |
| } | |
| $removablePath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\RemovableStorageDevices" | |
| if (Test-Path $removablePath) { | |
| Remove-Item -Path $removablePath -Force -Recurse -ErrorAction SilentlyContinue | |
| Write-Host " [OK] Removable storage policy removed" -ForegroundColor Green | |
| } | |
| # 9. RESTORE AUTOPLAY | |
| Write-Host "`n[9] Restoring AutoPlay..." -ForegroundColor Yellow | |
| $apPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer" | |
| if (Test-Path $apPath) { | |
| Remove-ItemProperty -Path $apPath -Name "NoDriveTypeAutoRun" -ErrorAction SilentlyContinue | |
| Remove-ItemProperty -Path $apPath -Name "NoAutorun" -ErrorAction SilentlyContinue | |
| Write-Host " [OK] AutoPlay policy removed" -ForegroundColor Green | |
| } | |
| # 10. RESTORE BLUETOOTH | |
| Write-Host "`n[10] Restoring Bluetooth..." -ForegroundColor Yellow | |
| $btSvc = Get-Service -Name "bthserv" -ErrorAction SilentlyContinue | |
| if ($btSvc) { | |
| Set-Service -Name "bthserv" -StartupType Manual -ErrorAction SilentlyContinue | |
| Write-Host " [OK] Bluetooth service restored" -ForegroundColor Green | |
| } | |
| $btReg = "HKLM:\SYSTEM\CurrentControlSet\Services\BTHUSB" | |
| if (Test-Path $btReg) { | |
| Set-ItemProperty -Path $btReg -Name "Start" -Value 3 -Force | |
| Write-Host " [OK] Bluetooth driver restored" -ForegroundColor Green | |
| } | |
| # DONE | |
| Write-Host "`n========================================" -ForegroundColor Green | |
| Write-Host " ALL BLOCKS REMOVED - NETWORK RESTORED!" -ForegroundColor Green | |
| Write-Host "========================================`n" -ForegroundColor Green | |
| Write-Host "Summary:" -ForegroundColor White | |
| Write-Host " [OK] Firewall reset to default" -ForegroundColor Green | |
| Write-Host " [OK] All block rules removed" -ForegroundColor Green | |
| Write-Host " [OK] Outbound traffic = ALLOWED" -ForegroundColor Green | |
| Write-Host " [OK] Windows Update restored" -ForegroundColor Green | |
| Write-Host " [OK] OneDrive restored" -ForegroundColor Green | |
| Write-Host " [OK] Hosts file cleaned" -ForegroundColor Green | |
| Write-Host " [OK] USB Storage restored" -ForegroundColor Green | |
| Write-Host " [OK] AutoPlay restored" -ForegroundColor Green | |
| Write-Host " [OK] Bluetooth restored" -ForegroundColor Green | |
| Write-Host "" | |
| Write-Host "YOUR COMPUTER CAN NOW CONNECT TO THE INTERNET NORMALLY." -ForegroundColor Green | |
| Write-Host "" | |
| $resp = Read-Host "Restart now? (Y/N)" | |
| if ($resp -eq "Y" -or $resp -eq "y") { | |
| Write-Host "Restarting in 5 seconds..." -ForegroundColor Yellow | |
| Start-Sleep -Seconds 5 | |
| Restart-Computer | |
| } else { | |
| Write-Host "Please restart manually." -ForegroundColor Cyan | |
| } | |
Xet Storage Details
- Size:
- 7.78 kB
- Xet hash:
- 883b90473c8e7a8fc9ff7a165cd80b9eacaa6f6bad88fd76d230c08dd78b764e
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.