From 8874c1dc39e0901ea958cfaab8206ee7f4e3c6e9 Mon Sep 17 00:00:00 2001 From: Trond Hindenes Date: Sun, 6 Nov 2016 17:01:49 +0100 Subject: [PATCH] Improved Get-PendingRebootStatus --- lib/ansible/module_utils/powershell.ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/ansible/module_utils/powershell.ps1 b/lib/ansible/module_utils/powershell.ps1 index 7823c048aca..73a9954610c 100644 --- a/lib/ansible/module_utils/powershell.ps1 +++ b/lib/ansible/module_utils/powershell.ps1 @@ -236,7 +236,8 @@ Function Get-PendingRebootStatus #Function returns true if computer has a pending reboot $featureData = invoke-wmimethod -EA Ignore -Name GetServerFeature -namespace root\microsoft\windows\servermanager -Class MSFT_ServerManagerTasks $regData = Get-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager" "PendingFileRenameOperations" -EA Ignore - if(($featureData -and $featureData.RequiresReboot) -or $regData) + $CBSRebootStatus = Get-ChildItem "HKLM:\\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing" -ErrorAction SilentlyContinue| where {$_.PSChildName -eq "RebootPending"} + if(($featureData -and $featureData.RequiresReboot) -or $regData -or $CBSRebootStatus) { return $True }