1- # Reg keys are documented here: https://learn.microsoft.com/en-us/mem/configmgr/core/servers/deploy/install/list-of-prerequisite-checks#pending-system-restart
2- if (Get-ChildItem " HKLM:\Software\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending" - EA Ignore) { return @ { rebootPending = $true } | ConvertTo-Json - Compress }
3- if (Get-Item " HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired" - EA Ignore) { return @ { rebootPending = $true } | ConvertTo-Json - Compress }
4- if (Get-ItemProperty " HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager" - Name PendingFileRenameOperations - EA Ignore) { return @ { rebootPending = $true } | ConvertTo-Json - Compress }
5- try {
6- $util = [wmiclass ]" \\.\root\ccm\clientsdk:CCM_ClientUtilities"
7- $status = $util.DetermineIfRebootPending ()
8- if (($status -ne $null ) -and $status.RebootPending ){
9- return @ { rebootPending = $true } | ConvertTo-Json - Compress
10- }
11- }catch {}
12-
13- return @ { rebootPending = $false } | ConvertTo-Json - Compress
1+ # Copyright (c) Microsoft Corporation.
2+ # Licensed under the MIT License.
3+
4+ # Reg keys are documented here: https://learn.microsoft.com/en-us/mem/configmgr/core/servers/deploy/install/list-of-prerequisite-checks#pending-system-restart
5+ $reasons = [System.Collections.Generic.List [string []]]::new()
6+ if (Get-ChildItem " HKLM:\Software\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending" - EA Ignore) {
7+ $reasons.Add (" Component Based Servicing" )
8+ }
9+ if (Get-Item " HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired" - EA Ignore) {
10+ $reasons.Add (" Windows Update" )
11+ }
12+ if (Get-ItemProperty " HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager" - Name PendingFileRenameOperations - EA Ignore) {
13+ $reasons.Add (" Pending File Rename Operations" )
14+ }
15+ try {
16+ $util = [wmiclass ]" \\.\root\ccm\clientsdk:CCM_ClientUtilities"
17+ $status = $util.DetermineIfRebootPending ()
18+ if (($null -ne $status ) -and $status.RebootPending ){
19+ $reasons.Add (" SCCM Client" )
20+ }
21+ }catch {}
22+
23+ $result = @ {
24+ rebootPending = $reasons.Count -gt 0
25+ reason = if ($reasons.Count -gt 0 ) { $reasons } else { $null }
26+ }
27+
28+ return $result | ConvertTo-Json - Compress
0 commit comments