Last active
December 3, 2021 21:53
-
-
Save themaximax/2fa3caae3ddee839fae6944aaf02ae39 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Скрипт автоматической настройки школьного интернета v0.3.1 | |
# Макс Максимов, https://vk.com/itmax | |
$cert = 'ca.root.crt' | |
$server = '10.0.46.52' #'77.34.90.72' | |
$port = '3128' | |
$bypassList = '192.168.*;10.*;<local>' | |
# Для совместимости со старыми версиями powershell | |
if ($PSScriptRoot -eq $null) { | |
$PSScriptRoot = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition | |
} | |
if ($PSCommandPath -eq $null) { | |
$PSCommandPath = $MyInvocation.MyCommand.Definition | |
} | |
Write-Host '=== СКРИПТ АВТОМАТИЧЕСКОЙ НАСТРОЙКИ ШКОЛЬНОГО ИНТЕРНЕТА ===' -ForegroundColor White -BackgroundColor Blue | |
Start-Sleep 1 | |
Clear-Host | |
#Проверка прав администратора, если их нет то перезапускаем скрипт с правами админа | |
If (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { | |
Write-Warning 'Нет прав администратора!' | |
Start-Sleep -Milliseconds 500 | |
Write-Host 'Пробую запустить с правами админа...' | |
Write-Host "`nНажмите `"Да`" в окне `"Контроль учетных записей пользователей`"" | |
Start-Process powershell.exe -ArgumentList '-NoProfile', '-ExecutionPolicy Bypass', "-File `"$PSCommandPath`"", "`"$args`"" -Verb RunAs | |
Exit | |
} | |
Set-Location $PSScriptRoot | |
Write-Host 'Устанавливаю корневой сертификат Ростелекома...' -ForegroundColor Magenta | |
Start-Sleep -Milliseconds 500 | |
certutil.exe -Enterprise -AddStore "Root" $cert | |
Write-Host '-----------------------------' | |
$proxyServer = -Join($server, ':', $port) | |
Write-Host "Проверяю доступность прокси-сервера $proxyServer..." -ForegroundColor Magenta | |
If (Test-Connection $server -Count 2 -ErrorAction SilentlyContinue) { | |
Write-Host '> Соединение установлено!' -ForegroundColor Green | |
} else { | |
Write-Warning "Прокси-сервер $proxyServer недоступен!" | |
Write-Host 'Проверьте наличие проводного соединения или Wi-Fi' | |
$ansver = Read-Host "Произвести настройку, несмотря на отсутсвие подключения к серверу?`nДа/Нет" | |
$ansver = $ansver.ToLower().Trim() | |
if ($ansver -ne 'да') { | |
Exit | |
} | |
} | |
$regPath = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' | |
Set-ItemProperty -Path $regPath -Name ProxyEnable -Value 1 | |
Set-ItemProperty -Path $regPath -Name ProxyServer -Value $proxyServer | |
Set-ItemProperty -Path $regPath -Name ProxyOverride -Value $bypassList | |
netsh.exe WinHTTP Set Proxy Proxy-Server=$proxyServer Bypass-List=$bypassList | |
Write-Host '-----------------------------' | |
Write-Host 'НАСТРОЙКИ ЗАВЕРШЕНЫ!' -ForegroundColor Green | |
Start-Sleep 5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment