Skip to content

Configuring Windows Services

Jesper Nielsen edited this page Mar 16, 2026 · 1 revision

Configure and reconfigure Windows Services. Set the startup type and running state of Windows services to match your organization's baseline.

Important

This module requires installBehavior to be set to SYSTEM. Configuring Windows services requires elevated SYSTEM context. If the configuration uses USER install behavior, the module logs an error and is skipped.

Overview

The windowsServices module configures and manages Windows Services startup types and states. It controls service behavior to ensure consistent configuration across managed devices.

For each configured service, the module performs the following steps:

  1. Queries the current service status using Get-Service
  2. Retrieves the current StartType (Automatic, Manual, Disabled) and Status (Running, Stopped)
  3. Compares the current StartType with the desired configuration
  4. If different, reconfigures the service StartType using Set-Service
  5. Optionally stops running services if StopIfRunning is enabled

The module is non-destructive - it only changes services that do not match the desired configuration. Service existence is verified before attempting any modifications.

Common use cases include disabling unnecessary services to improve performance or security, setting critical services to automatic startup, stopping and disabling telemetry or diagnostic services, and configuring services for enterprise compliance requirements.

Configuration

The following shows the windowsServices configuration structure with examples of different startup types and the StopIfRunning option.

{
  "windowsServices": {
    "enabled": true,
    "services": [
      {
        "Name": "XboxGipSvc",
        "DisplayName": "Xbox Accessory Management Service",
        "StartType": "Manual",
        "StopIfRunning": false
      },
      {
        "Name": "seclogon",
        "DisplayName": "Secondary Logon",
        "StartType": "Disabled",
        "StopIfRunning": true
      }
    ]
  }
}

Dataset properties

The following properties are supported in the windowsServices section.

Property Description Type Required
windowsServices
enabled Enable or disable the module Boolean No
services (array)
Name Service name as returned by Get-Service String Yes
DisplayName Friendly name of the service - used for logging and readability String No
StartType Desired startup type - Automatic, Manual, Disabled, Boot, System, or LeaveAsIs String Yes
StopIfRunning Stop the service if it is currently running. Uses -Force flag to ensure the service stops Boolean No

Reference

The commands below must be run from an elevated PowerShell prompt (Run as Administrator).

List all services

List all Windows services sorted by name with their current status and startup type.

Get-Service | Sort-Object "Name" | Select-Object "Name", "DisplayName", "Status", "StartType" | Format-Table -AutoSize

Search for a specific service

Search for a service by name using a wildcard pattern.

Get-Service -Name "*xbox*" | Select-Object "Name", "DisplayName", "Status", "StartType"

Check service startup type

Retrieve the startup type of a specific service.

Get-Service -Name "seclogon" | Select-Object "Name", "DisplayName", "Status", "StartType"

Related resources

For more information, see the following resources.

  • Get-Service - PowerShell reference for listing Windows services
  • Set-Service - PowerShell reference for configuring Windows services

Page revised: March 4, 2026

Clone this wiki locally