From 4b30ddb769aefb58e3a0138b19335d2602b08e3f Mon Sep 17 00:00:00 2001 From: "G.Reijn" <26114636+Gijsreyn@users.noreply.github.com> Date: Sat, 9 May 2026 11:23:23 +0200 Subject: [PATCH 1/2] docs: Add reference documentation for Microsoft.Windows/Service --- .../examples/configure-windows-service.md | 212 +++++++++ .../Service/examples/get-service-status.md | 86 ++++ .../Service/examples/service.config.dsc.yaml | 15 + .../Microsoft/Windows/Service/index.md | 424 ++++++++++++++++++ 4 files changed, 737 insertions(+) create mode 100644 docs/reference/resources/Microsoft/Windows/Service/examples/configure-windows-service.md create mode 100644 docs/reference/resources/Microsoft/Windows/Service/examples/get-service-status.md create mode 100644 docs/reference/resources/Microsoft/Windows/Service/examples/service.config.dsc.yaml create mode 100644 docs/reference/resources/Microsoft/Windows/Service/index.md 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..780242e1a --- /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 (`w32tm`) 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: