File tree Expand file tree Collapse file tree 1 file changed +10
-11
lines changed
Expand file tree Collapse file tree 1 file changed +10
-11
lines changed Original file line number Diff line number Diff line change @@ -16,19 +16,18 @@ Describe 'reboot_pending resource tests' {
1616 }
1717
1818 It ' reboot_pending should have a reason' - Skip:(! $IsWindows ) {
19- BeforeAll {
20- # Ensure the system is in a state that requires a reboot
21- if (-not (Get-ItemProperty " HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired" - ErrorAction SilentlyContinue)) {
22- New-ItemProperty - Path " HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update" - Name " RebootRequired" - Value 1 - PropertyType DWord - Force | Out-Null
19+ $keyPath = " HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update"
20+ $keyName = " RebootRequired"
21+ try {
22+ if (-not (Get-ItemProperty " $keyPath \$keyName " - ErrorAction SilentlyContinue)) {
23+ New-ItemProperty - Path $keyPath - Name $keyName - Value 1 - PropertyType DWord - Force | Out-Null
2324 }
24- }
25-
26- $out = dsc resource get - r Microsoft.Windows/ RebootPending | ConvertFrom-Json
27- $LASTEXITCODE | Should - Be 0
28- $out.actualState.reason | Should -Not - BeNullOrEmpty
2925
30- AfterAll {
31- Remove-ItemProperty - Path " HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update" - Name " RebootRequired" - ErrorAction SilentlyContinue
26+ $out | dsc resource get - r Microsoft.Windows/ RebootPending | ConvertFrom-Json
27+ $LASTEXITCODE | Should - Be 0
28+ $out.actualState.reason | Should -Not - BeNullOrEmpty
29+ } finally {
30+ Remove-ItemProperty - Path $keyPath - Name $keyName - ErrorAction SilentlyContinue
3231 }
3332 }
3433}
You can’t perform that action at this time.
0 commit comments