File tree Expand file tree Collapse file tree 4 files changed +51
-18
lines changed Expand file tree Collapse file tree 4 files changed +51
-18
lines changed Original file line number Diff line number Diff line change 11{
2- "$schema" : " https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/bundled/resource/manifest.json" ,
3- "description" : " Returns info about pending reboot." ,
4- "type" : " Microsoft.Windows/RebootPending" ,
5- "version" : " 0.1.0" ,
6- "get" : {
7- "executable" : " powershell" ,
8- "args" : [
9- " -NoLogo" ,
10- " -NonInteractive" ,
11- " -NoProfile" ,
12- " -Command" ,
13- " reboot_pending.resource.ps1"
14- ]
2+ "$schema" : " https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/bundled/resource/manifest.json" ,
3+ "description" : " Returns info about pending reboot." ,
4+ "type" : " Microsoft.Windows/RebootPending" ,
5+ "version" : " 0.1.0" ,
6+ "get" : {
7+ "executable" : " powershell" ,
8+ "args" : [
9+ " -NoLogo" ,
10+ " -NonInteractive" ,
11+ " -NoProfile" ,
12+ " -Command" ,
13+ " reboot_pending.resource.ps1"
14+ ]
15+ },
16+ "schema" : {
17+ "embedded" : {
18+ "$schema" : " https://json-schema.org/draft/2020-12/schema" ,
19+ "type" : " null" ,
20+ "properties" : {
21+ "rebootPending" : {
22+ "type" : " boolean" ,
23+ "readOnly" : true
24+ }
25+ }
1526 }
27+ }
1628}
Original file line number Diff line number Diff line change 11 # 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 }
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 }
55 try {
66 $util = [wmiclass ]" \\.\root\ccm\clientsdk:CCM_ClientUtilities"
77 $status = $util.DetermineIfRebootPending ()
88 if (($status -ne $null ) -and $status.RebootPending ){
9- return @ { RebootPending = $true } | ConvertTo-Json - Compress
9+ return @ { rebootPending = $true } | ConvertTo-Json - Compress
1010 }
1111 }catch {}
1212
13- return @ { RebootPending = $false } | ConvertTo-Json - Compress
13+ return @ { rebootPending = $false } | ConvertTo-Json - Compress
Original file line number Diff line number Diff line change 1+ $schema : https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
2+ resources :
3+ - name : Pending reboot status
4+ type : Microsoft.Windows/RebootPending
Original file line number Diff line number Diff line change 1+ # Copyright (c) Microsoft Corporation.
2+ # Licensed under the MIT License.
3+
4+ Describe ' reboot_pending resource tests' {
5+ It ' should get reboot_pending' - Skip:(! $IsWindows ) {
6+ $out = dsc resource get - r Microsoft.Windows/ RebootPending | ConvertFrom-Json
7+ $LASTEXITCODE | Should - Be 0
8+ $out.actualState.rebootPending | Should -Not - BeNullOrEmpty
9+ }
10+
11+ It ' reboot_pending works in a config' - Skip:(! $IsWindows ) {
12+ $ConfigPath = Resolve-Path " $PSScriptRoot /reboot_pending.dsc.yaml"
13+ $out = dsc config get -- path $ConfigPath | ConvertFrom-Json
14+ $LASTEXITCODE | Should - Be 0
15+ $out.results.result.actualState.rebootPending | Should -Not - BeNullOrEmpty
16+ }
17+ }
You can’t perform that action at this time.
0 commit comments