Загрузка данных



#requires -RunAsAdministrator
# Windows 10/11
# Запрет автоматических обновлений и перезагрузок

$ErrorActionPreference = "Stop"

Write-Host "`n=== Настройка Windows Update ===" -ForegroundColor Cyan

# 1. Политики Windows Update
$wuPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate"
$auPath = "$wuPath\AU"

New-Item -Path $wuPath -Force | Out-Null
New-Item -Path $auPath -Force | Out-Null

# 2. Отключить автоматическое обновление
Set-ItemProperty -Path $auPath `
    -Name "NoAutoUpdate" -Value 1 -Type DWord

# Не перезагружать ПК, если пользователь вошёл в систему
Set-ItemProperty -Path $auPath `
    -Name "NoAutoRebootWithLoggedOnUsers" -Value 1 -Type DWord

# Не выполнять автоматическую перезагрузку по расписанию
Set-ItemProperty -Path $auPath `
    -Name "AlwaysAutoRebootAtScheduledTime" -Value 0 -Type DWord

# 3. Отключить автоматическую перезагрузку через Update Orchestrator
$orchestratorPath = "HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings"
New-Item -Path $orchestratorPath -Force | Out-Null

Set-ItemProperty -Path $orchestratorPath `
    -Name "IsExpedited" -Value 0 -Type DWord `
    -ErrorAction SilentlyContinue

# 4. Запретить автоматическую перезагрузку через Active Hours
# Установить максимально допустимое окно активности
Set-ItemProperty -Path $orchestratorPath `
    -Name "SetActiveHours" -Value 1 -Type DWord

Set-ItemProperty -Path $orchestratorPath `
    -Name "ActiveHoursStart" -Value 0 -Type DWord

Set-ItemProperty -Path $orchestratorPath `
    -Name "ActiveHoursEnd" -Value 23 -Type DWord

# 5. Обновить групповые политики
Write-Host "`n=== Обновление групповых политик ===" -ForegroundColor Cyan
gpupdate /target:computer /force

# 6. Показать итоговые настройки
Write-Host "`n=== Проверка настроек ===" -ForegroundColor Green

Get-ItemProperty $auPath |
    Select-Object NoAutoUpdate,
                  NoAutoRebootWithLoggedOnUsers,
                  AlwaysAutoRebootAtScheduledTime |
    Format-List

Write-Host "`nГотово. Проверьте, не переопределяет ли настройки доменная GPO." `
    -ForegroundColor Yellow