From d57084360b4ecf0b216d7407c6b08e8950f19019 Mon Sep 17 00:00:00 2001 From: UrBnW <40244829+UrBnW@users.noreply.github.com> Date: Thu, 6 Aug 2020 19:34:34 +0200 Subject: [PATCH] fix(windows) local rebootpending --- centreon/common/powershell/windows/pendingreboot.pm | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/centreon/common/powershell/windows/pendingreboot.pm b/centreon/common/powershell/windows/pendingreboot.pm index a7dfc1abc..39165848f 100644 --- a/centreon/common/powershell/windows/pendingreboot.pm +++ b/centreon/common/powershell/windows/pendingreboot.pm @@ -47,16 +47,12 @@ Try { ## Setting CBSRebootPend to null since not all versions of Windows has this value $CBSRebootPend = $null - ## Querying WMI for build version - $WMI_OS = Get-WmiObject -Class Win32_OperatingSystem -Property BuildNumber, CSName -ComputerName $ComputerName -ErrorAction Stop - ## Making registry connection to the local/remote computer $HKLM = [UInt32] "0x80000002" $WMI_Reg = [WMIClass] "\\\\$ComputerName\\root\\default:StdRegProv" - ## If Vista/2008 & Above query the CBS Reg Key - If ([Int32]$WMI_OS.BuildNumber -ge 6001) { - $RegSubKeysCBS = $WMI_Reg.EnumKey($HKLM,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Component Based Servicing\\") + $RegSubKeysCBS = $WMI_Reg.EnumKey($HKLM,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Component Based Servicing\\") + If ($RegSubKeysCBS.ReturnValue -eq 0) { $CBSRebootPend = $RegSubKeysCBS.sNames -contains "RebootPending" }