Admin Future
241 subscribers
51 photos
1 video
4 files
120 links
Превращаем эникейщиков в System Architects.
🚀 Твой навигатор в мире IT-инфраструктуры:

▪️ Hard Skills: Linux, Windows, Network, Security
▪️ Tools: Лучший софт и скрытые фишки
▪️ Mindset: Как думать, чтобы платили много


Админ - @maksimshap
Download Telegram
🕵️‍♂️ PowerShell: Кто ждет перезагрузки?

В контексте разговоров о патчах и Hotpatching, важно знать правду: действительно ли ваши серверы применили обновления? Часто сервер висит в статусе PendingReboot неделями, оставаясь уязвимым.

Скрипт проверяет 4 места в реестре, где Windows прячет флаг "хочу ребут".

Код:


function Get-PendingReboot {
param([string]$ComputerName = "localhost")

$HKLM = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $ComputerName)

# 1. Component Based Servicing
$CBS = $HKLM.OpenSubKey('SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending')

# 2. Windows Update
$WU = $HKLM.OpenSubKey('SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired')

# 3. File Rename Operations
$SM = $HKLM.OpenSubKey('SYSTEM\CurrentControlSet\Control\Session Manager')
$Rename = $SM.GetValue('PendingFileRenameOperations')

# Итог
[PSCustomObject]@{
Computer = $ComputerName
CBSPending = [bool]$CBS
WUPending = [bool]$WU
FileRenamePending = [bool]$Rename
IS_REBOOT_REQUIRED = ([bool]$CBS -or [bool]$WU -or [bool]$Rename)
}
}

# Использование:
# Get-PendingReboot -ComputerName "SRV-AD01"

📌 Задача: Добавьте этот чек в свой утренний мониторинг. Сервер, ожидающий перезагрузки — это не защищенный сервер.

#powershell #scripting #windowsupdate #automation #security