# === Copyright (C) 20XX "PS.OnlineDriverUpdate" by zetod1ce [github.com/ztd38f] === # <# [!] ДИСКЛЕЙМЕР [!] Автор полностью отказывается от какой-либо ответственности за использование данного скрипта. Скрипт предоставляется "КАК ЕСТЬ", может быть изменён или дополнен в любое время без уведомления. Использование допускается только для личного обучения в строго контролируемой среде под надзором профессионалов. Всё использование осуществляется исключительно на ваш страх и риск. [!] DISCLAIMER [!] The author fully disclaims any responsibility for the use of this script. The script is provided "AS IS" and may be changed or updated at any time without notice. Use is permitted only for personal educational purposes in a strictly controlled environment under professional supervision. All use is entirely at your own risk. #> [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 # ============================== # === 1. Проверка прав === # ============================== if (!([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole( [Security.Principal.WindowsBuiltinRole]::Administrator)) { Write-Warning "⚠️ Запусти PowerShell от имени администратора!" sleep 3 pause } # ============================== # === 2. Подготовка окружения === # ============================== $session=New-Object -ComObject Microsoft.Update.Session;$searcher=$session.CreateUpdateSearcher();$result=$searcher.Search("IsInstalled=0 and IsHidden=0");$updates=New-Object -ComObject Microsoft.Update.UpdateColl; $result.Updates | % { $updates.Add($_) | Out-Null }; if ($updates.Count -gt 0) { $installer=$session.CreateUpdateInstaller(); $installer.Updates=$updates; $installer.Install() } $LogPath = "$env:SystemRoot\Logs\DriverUpdate_$(Get-Date -Format 'yyyyMMdd_HHmmss').log" Write-Host "📋 Лог записывается в: $LogPath" -f DarkGray Write-Output "`n===== START $(Get-Date) =====`n" | Out-File -FilePath $LogPath -Encoding UTF8 -Append # Проверяем и устанавливаем модуль PSWindowsUpdate if (!(Get-Module -ListAvailable -Name PSWindowsUpdate)) { Write-Host "📦 Устанавливаю модуль PSWindowsUpdate..." -f Yellow Install-PackageProvider -Name NuGet -Force -ErrorAction SilentlyContinue Install-Module -Name PSWindowsUpdate -Force -ErrorAction Stop } Import-Module PSWindowsUpdate # Добавляем Microsoft Update (чтобы обновления драйверов были от OEM) if (!(Get-WUServiceManager | Where-Object {$_.ServiceID -like "*Microsoft Update*"})) { Write-Host "🔗 Подключаю Microsoft Update..." -f Yellow Add-WUServiceManager -MicrosoftUpdate -Confirm:$false | Out-Null } # ============================== # === 3. Проверка обновлений === # ============================== Write-Host "`n🔍 Проверяю наличие обновлений драйверов..." -f Cyan $Drivers = Get-WindowsUpdate -MicrosoftUpdate -Category Drivers -IgnoreReboot -ErrorAction SilentlyContinue if (!($Drivers)) { Write-Host "✅ Все драйверы актуальны. Обновления не требуются." -f Green Write-Output "No driver updates found." | Out-File -FilePath $LogPath -Append pause } # ============================== # === 4. Отображение найденного === # ============================== Write-Host "`n📦 Найдены обновления драйверов:" -f Yellow $Drivers | Select-Object -Property Title, KB, Size, MsrcSeverity | Format-Table -AutoSize $Count = $Drivers.Count Write-Host "`nНайдено $Count драйвер(ов). Установить их?" -f Cyan $Confirm = Read-Host "Введите Y (да) или N (нет)" if ($Confirm -ne 'Y' -and $Confirm -ne 'y') { Write-Host "❌ Установка отменена пользователем." -f Red Write-Output "User cancelled update." | Out-File -FilePath $LogPath -Append pause } # ============================== # === 5. Установка драйверов === # ============================== Write-Host "`n🚀 Начинаю установку драйверов..." -f Cyan Install-WindowsUpdate -MicrosoftUpdate -Category Drivers -AcceptAll -IgnoreReboot -Verbose -ErrorAction Continue | Tee-Object -FilePath $LogPath -Append Write-Host "`n✅ Установка драйверов завершена." -f Green # ============================== # === 6. Завершение === # ============================== Write-Host "`nХотите перезагрузить компьютер сейчас?" -f Cyan $Reboot = Read-Host "Введите Y (да) или N (нет)" if ($Reboot -eq 'Y' -or $Reboot -eq 'y') { Write-Host "🔁 Перезагрузка..." -f Yellow Restart-Computer } else { Write-Host "🟢 Перезагрузка отложена." -f Green } Write-Output "`n===== END $(Get-Date) =====`n" | Out-File -FilePath $LogPath -Append