diff --git a/docs/reference/resources/Microsoft/Windows/Service/examples/configure-windows-service.md b/docs/reference/resources/Microsoft/Windows/Service/examples/configure-windows-service.md new file mode 100644 index 000000000..0e961ba5c --- /dev/null +++ b/docs/reference/resources/Microsoft/Windows/Service/examples/configure-windows-service.md @@ -0,0 +1,212 @@ +--- +description: > + Example showing how to use the Microsoft.Windows/Service resource in a DSC configuration + document to enforce the desired state of Windows services. +ms.date: 05/08/2026 +ms.topic: reference +title: Configure a Windows service +--- + +# Configure a Windows service + +This example shows how you can use the `Microsoft.Windows/Service` resource in a DSC configuration +document to enforce the desired configuration and runtime status of multiple Windows services. + +> [!IMPORTANT] +> **Set** operations for this resource require an elevated (administrator) process context. Run +> your terminal or PowerShell session as Administrator before using `dsc config set`. + +## Definition + +The configuration document for this example defines two instances of the `Service` resource. + +The first instance ensures that the Windows Update service (`wuauserv`) is stopped and configured +for manual start. The second instance ensures that the Windows Time service (`W32Time`) is running +and configured to start automatically. + +:::code language="yaml" source="service.config.dsc.yaml"::: + +Copy the configuration document and save it as `service.config.dsc.yaml`. + +## Test the configuration + +To see whether the system is already in the desired state, use the [dsc config test][01] command. + +```powershell +dsc config test --file ./service.config.dsc.yaml +``` + +```yaml +executionInformation: + duration: