-
Notifications
You must be signed in to change notification settings - Fork 43
Add RebootPending and WindowsPowerShell reference documentation #857
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
michaeltlombardi
merged 15 commits into
PowerShell:main
from
Gijsreyn:update-reference-docs
Jun 19, 2025
Merged
Changes from 12 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
5e55535
Add reference documentation for rebootPending and WindowsPowerShell
Gijsreyn 272b9d2
Revert change on OSInfo
Gijsreyn b833eca
Fix link definitions
Gijsreyn 0d193f6
Format table
Gijsreyn c8e9c51
Clarification on script-based
Gijsreyn 67496da
Add reference documentation for rebootPending and WindowsPowerShell
Gijsreyn f72bc5d
Revert change on OSInfo
Gijsreyn 144828a
Fix link definitions
Gijsreyn da620cc
Format table
Gijsreyn d287999
Clarification on script-based
Gijsreyn b69b024
Merge branch 'update-reference-docs' of https://github.com/Gijsreyn/o…
Gijsreyn 2816d4d
Add exit codes and rephrase sentence
Gijsreyn efdaa76
Merge branch 'main' into update-reference-docs
Gijsreyn c013bdf
Resolve remarks
Gijsreyn 8130f87
Add reasons
Gijsreyn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
.../resources/Microsoft/Windows/RebootPending/examples/check-for-pending-reboot.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
description: > | ||
Example showing how to use the Microsoft.Windows/RebootPending resource with DSC to check if a Windows system has a pending reboot. | ||
ms.date: 03/25/2025 | ||
ms.topic: reference | ||
title: Check for pending reboot | ||
--- | ||
|
||
# Check for pending reboot | ||
|
||
This example shows how you can use the `Microsoft.Windows/RebootPending` resource to check whether a Windows system has a pending reboot. | ||
|
||
## Check reboot status | ||
|
||
The following snippet shows how to use the resource with the [dsc resource get][01] command to retrieve the pending reboot status. | ||
|
||
```powershell | ||
dsc resource get --resource Microsoft.Windows/RebootPending | ||
``` | ||
|
||
When you run this command, DSC returns the following result if a reboot is pending: | ||
|
||
```yaml | ||
actualState: | ||
rebootPending: true | ||
``` | ||
|
||
If no reboot is pending, the result is: | ||
|
||
```yaml | ||
actualState: | ||
rebootPending: false | ||
``` | ||
|
||
The `rebootPending` property indicates whether the system requires a reboot (`true`) or not (`false`). | ||
|
||
> [!NOTE] | ||
> You can only use the **Get** operation to check the reboot status. | ||
> The resource does not support **Set**, **WhatIf**, **Export**, **Delete**, or **Test** operations. | ||
|
||
<!-- Link reference definitions --> | ||
[01]: ../../../../../cli/resource/get.md |
19 changes: 19 additions & 0 deletions
19
...eference/resources/Microsoft/Windows/RebootPending/examples/pendingReboot.config.dsc.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# yaml-language-server: $schema=https://aka.ms/dsc/schemas/v3/bundled/config/document.vscode.json | ||
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json | ||
resources: | ||
- name: Managed key | ||
type: Microsoft.Windows/Registry | ||
properties: | ||
_exist: true | ||
keyPath: HKCU\DscExamples\ManagedKey | ||
dependsOn: | ||
- "[resourceId('Microsoft.DSC/Assertion','Assert pending reboot')]" | ||
- name: Assert pending reboot | ||
type: Microsoft.DSC/Assertion | ||
properties: | ||
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json | ||
resources: | ||
- name: Check pending reboot | ||
type: Microsoft.Windows/RebootPending | ||
properties: | ||
rebootPending: true |
253 changes: 253 additions & 0 deletions
253
.../Microsoft/Windows/RebootPending/examples/use-rebootpending-in-configuration.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,253 @@ | ||
--- | ||
description: > | ||
Example showing how to use the Microsoft.Windows/RebootPending resource in a | ||
configuration document with an assertion to check for a pending reboot. | ||
ms.date: 03/25/2025 | ||
ms.topic: reference | ||
title: Use RebootPending resource in a configuration | ||
--- | ||
|
||
# Use the RebootPending resource in a configuration | ||
|
||
This example demonstrates how to use the `Microsoft.Windows/RebootPending` resource in a configuration document. | ||
The configuration checks if a reboot is pending and, if so, skips the subsequent step using an assertion. | ||
|
||
## Definition | ||
|
||
This configuration document demonstrates how to use the `Microsoft.Windows/RebootPending` resource together with an assertion. | ||
|
||
The first instance defines the desired state for the `ManagedKey` registry key, ensuring it | ||
exists only if no reboot is pending. It uses the `dependsOn` property to reference the assertion resource, | ||
which checks the system's reboot status using the `Microsoft.Windows/RebootPending` resource. | ||
The assertion passes when `rebootPending` is `false`,allowing the registry key resource to run. | ||
If a reboot is pending, the assertion fails and the registry key is not set. | ||
|
||
:::code language="yaml" source="pendingReboot.config.dsc.yaml"::: | ||
|
||
Copy the configuration document and save it as `pendingReboot.config.dsc.yaml`. | ||
|
||
## Test configuration | ||
|
||
To see whether the system is in the desired state, use the [dsc config test][01] command on the | ||
configuration document. | ||
|
||
```powershell | ||
dsc config test --file ./pendingReboot.config.dsc.yaml | ||
``` | ||
|
||
```yaml | ||
metadata: | ||
Microsoft.DSC: | ||
version: 3.0.0 | ||
operation: test | ||
executionType: actual | ||
startDatetime: 2025-06-03T06:49:22.573486200+02:00 | ||
endDatetime: 2025-06-03T06:49:35.813770500+02:00 | ||
duration: PT13.2402843S | ||
securityContext: restricted | ||
results: | ||
- metadata: | ||
Microsoft.DSC: | ||
duration: PT10.0162818S | ||
name: Assert pending reboot | ||
type: Microsoft.DSC/Assertion | ||
result: | ||
desiredState: | ||
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json | ||
resources: | ||
- name: Check pending reboot | ||
type: Microsoft.Windows/RebootPending | ||
properties: | ||
rebootPending: false | ||
actualState: | ||
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json | ||
contentVersion: 1.0.0 | ||
resources: | ||
- type: Microsoft.Windows/RebootPending | ||
name: Check pending reboot | ||
properties: | ||
rebootPending: false | ||
inDesiredState: true | ||
differingProperties: [] | ||
- metadata: | ||
Microsoft.DSC: | ||
duration: PT0.0549784S | ||
name: Managed key | ||
type: Microsoft.Windows/Registry | ||
result: | ||
desiredState: | ||
_exist: true | ||
keyPath: HKCU\DscExamples\ManagedKey | ||
actualState: | ||
keyPath: HKCU\DscExamples\ManagedKey | ||
_exist: false | ||
inDesiredState: false | ||
differingProperties: | ||
- _exist | ||
messages: [] | ||
hadErrors: false | ||
``` | ||
|
||
Review the individual results to understand whether each instance is in the desired state. | ||
|
||
The result for the first instance, named `Check pending reboot`, was: | ||
|
||
```yaml | ||
desiredState: | ||
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json | ||
resources: | ||
- name: Check pending reboot | ||
type: Microsoft.Windows/RebootPending | ||
properties: | ||
rebootPending: false | ||
actualState: | ||
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json | ||
contentVersion: 1.0.0 | ||
resources: | ||
- type: Microsoft.Windows/RebootPending | ||
name: Check pending reboot | ||
properties: | ||
rebootPending: false | ||
inDesiredState: true | ||
differingProperties: [] | ||
``` | ||
|
||
The output indicates there is no pending reboot. When you use the **Set** operation on | ||
this confifguration, the second instance will run. | ||
|
||
The result for the second instance, named `Managed value`, was: | ||
|
||
```yaml | ||
desiredState: | ||
_exist: true | ||
keyPath: HKCU\DscExamples\ManagedKey | ||
actualState: | ||
keyPath: HKCU\DscExamples\ManagedKey | ||
_exist: false | ||
inDesiredState: false | ||
differingProperties: | ||
- _exist | ||
``` | ||
|
||
The output indicates the registry path doesn't exist. | ||
|
||
The first instance indicates the resource is in the desired state. The second | ||
instance indicates it isn't in the desired state. | ||
|
||
## Enforce configuration | ||
|
||
To update the system to the desired state, use the [dsc config set][02] command on the configuration document. | ||
|
||
```powershell | ||
dsc config set --file ./pendingReboot.config.dsc.yaml | ||
``` | ||
|
||
```yaml | ||
metadata: | ||
Microsoft.DSC: | ||
version: 3.0.0 | ||
operation: set | ||
executionType: actual | ||
startDatetime: 2025-06-03T06:55:12.123456+02:00 | ||
endDatetime: 2025-06-03T06:55:15.654321+02:00 | ||
duration: PT3.530865S | ||
securityContext: restricted | ||
results: | ||
- metadata: | ||
Microsoft.DSC: | ||
duration: PT2.000000S | ||
name: Assert pending reboot | ||
type: Microsoft.DSC/Assertion | ||
result: | ||
beforeState: | ||
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json | ||
resources: | ||
- name: Check pending reboot | ||
type: Microsoft.Windows/RebootPending | ||
properties: | ||
rebootPending: false | ||
afterState: | ||
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json | ||
resources: | ||
- name: Check pending reboot | ||
type: Microsoft.Windows/RebootPending | ||
properties: | ||
rebootPending: false | ||
changedProperties: [] | ||
- metadata: | ||
Microsoft.DSC: | ||
duration: PT0.0549784S | ||
name: Managed key | ||
type: Microsoft.Windows/Registry | ||
result: | ||
beforeState: | ||
keyPath: HKCU\DscExamples\ManagedKey | ||
_exist: false | ||
afterState: | ||
keyPath: HKCU\DscExamples\ManagedKey | ||
changedProperties: | ||
- _exist | ||
messages: [] | ||
hadErrors: false | ||
``` | ||
|
||
Review the individual results to understand how the resource modified the system to enforce the desired state for each instance. | ||
|
||
The result for the assertion instance, named `Assert pending reboot`, was: | ||
|
||
```yaml | ||
beforeState: | ||
- name: Check pending reboot | ||
type: Microsoft.Windows/RebootPending | ||
result: | ||
actualState: | ||
rebootPending: false | ||
afterState: | ||
- metadata: | ||
Microsoft.DSC: | ||
duration: PT0.5209322S | ||
name: Check pending reboot | ||
type: Microsoft.Windows/RebootPending | ||
result: | ||
desiredState: | ||
rebootPending: false | ||
actualState: | ||
rebootPending: false | ||
inDesiredState: true | ||
differingProperties: [] | ||
changedProperties: [] | ||
``` | ||
|
||
The output indicates the assertion passed and no changes were needed. | ||
|
||
The result for the registry key instance, named `Managed key`, was: | ||
|
||
```yaml | ||
beforeState: | ||
keyPath: HKCU\DscExamples\ManagedKey | ||
_exist: false | ||
afterState: | ||
keyPath: HKCU\DscExamples\ManagedKey | ||
changedProperties: | ||
- _exist | ||
``` | ||
|
||
The output indicates that the resource created the registry key. | ||
|
||
## Cleanup | ||
|
||
To return your system to its original state: | ||
|
||
1. Save the following configuration as `registry.cleanup.config.dsc.yaml`. | ||
|
||
:::code language="yaml" source="../../Registry/examples/registry.cleanup.config.dsc.yaml"::: | ||
|
||
2. Use the **Set** operation on the cleanup configuration document. | ||
|
||
```powershell | ||
dsc config set --file ./registry.cleanup.config.dsc.yaml | ||
``` | ||
|
||
<!-- Link reference definitions --> | ||
[01]: ../../../../../cli/config/test.md | ||
[02]: ../../../../../cli/config/set.md |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.