# --- Author: zetod1ce (github.com/ztd38f) --- # # --- DISCLAIMER: Provided as-is, without warranties. For educational and testing use only in controlled environments. Use at your own risk. --- # # --- Проверка прав --- # if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)) { start powershell -v runas "-NoProfile -ExecutionPolicy Bypass -Command `"iex (irm update-drivers.pages.dev)`"" return } # --- Подготовка окружения --- # $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() } iex (irm -useb psui.pages.dev) UI.Box "Update Drivers" "Cyan" # Проверяем и устанавливаем модуль PSWindowsUpdate if (!(Get-Module -ListAvailable -Name PSWindowsUpdate)) { UI.BoxSpinner { Install-PackageProvider -Name NuGet -Force -ea 0 Install-Module -Name PSWindowsUpdate -Force -ErrorAction Stop } "Устанавливаю модуль PSWindowsUpdate..." "Yellow" } Import-Module PSWindowsUpdate # Добавляем Microsoft Update (чтобы обновления драйверов были от OEM) if (!(Get-WUServiceManager | ? {$_.ServiceID -like "*Microsoft Update*"})) { UI.BoxSpinner { Add-WUServiceManager -MicrosoftUpdate -Confirm:$false | Out-Null } "Подключаю Microsoft Update..." "Yellow" } # --- Проверка обновлений --- # Write-Host "" $Drivers = @(UI.BoxSpinner { Get-WindowsUpdate -MicrosoftUpdate -Category Drivers -IgnoreReboot -ea 0 } "Проверяю наличие обновлений драйверов..." "Cyan")[0] if (!($Drivers)) { UI.Status "Все драйверы актуальны. Обновления не требуются." "ok" Write-Host "Press any key to continue . . . " -NoNewline -ForegroundColor DarkGray; $null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown"); Write-Host "" } # --- Отображение найденного --- # Write-Host "`nНайдены обновления драйверов:" -f Yellow $Drivers | Select-Object -Property Title, KB, Size, MsrcSeverity | Format-Table -AutoSize $Count = $Drivers.Count Write-Host "" if (!(UI.Confirm "Найдено $Count драйвер(ов). Установить их?")) { UI.Status "Установка отменена пользователем." "warn" Write-Host "Press any key to continue . . . " -NoNewline -ForegroundColor DarkGray; $null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown"); Write-Host "" } # --- Установка драйверов --- # UI.Box "Начинаю установку драйверов..." "Purple" Install-WindowsUpdate -MicrosoftUpdate -Category Drivers -AcceptAll -IgnoreReboot -Verbose -ErrorAction Continue UI.Box "Установка драйверов завершена." "Green" # --- Завершение --- # Write-Host "" if (UI.Confirm "Хотите перезагрузить компьютер сейчас?") { UI.Status "Перезагрузка..." "warn" Restart-Computer } else { UI.Status "Перезагрузка отложена." "ok" } UI.Pause