Skip to main content

Services on this PC that run as a domain or local account

Which services on this Windows device run as a domain or local user account instead of LocalSystem, LocalService or NetworkService?

WindowsWindows PowerShell 5.1 Read-only
Cmdlet lint
Passed
21 Nov 2026
Changes anything
No
Read-only
Pinned versions
1

Script

windows-services-running-as-accounts.ps1
#Requires -Version 5.1
# Services on this device that run as a domain or local account instead of a built-in service account. Read-only.
param(
    [switch]$IncludeVirtualAccounts
)

$computer = $env:COMPUTERNAME
$localSystemNames = @('LocalSystem', '.\LocalSystem', "$computer\LocalSystem")

$services = @(Get-CimInstance -ClassName Win32_Service -Property Name, DisplayName, StartName, State, StartMode, PathName |
    Where-Object {
        $account = "$($_.StartName)"
        $account -and
        $localSystemNames -notcontains $account -and
        $account -notlike 'NT AUTHORITY\*' -and
        ($IncludeVirtualAccounts -or $account -notlike 'NT SERVICE\*')
    })

if ($services.Count -eq 0) {
    Write-Output 'No service on this device runs as a domain or local account.'
}

$services |
    ForEach-Object {
        $account = "$($_.StartName)"
        $type = if ($account -like 'NT SERVICE\*') { 'Virtual' }
            elseif ($account -like '.\*' -or $account -like "$computer\*") { 'Local' }
            else { 'Domain' }
        [pscustomobject]@{
            Name        = $_.Name
            DisplayName = $_.DisplayName
            Account     = $account
            AccountType = $type
            State       = $_.State
            StartMode   = $_.StartMode
            PathName    = $_.PathName
        }
    } |
    Sort-Object AccountType, Account, Name

Checked automatically against Microsoft's published cmdlet reference. KBY hasn't run it in your tenant; run it in a test environment first.

Where to run it

The Windows device you want to check, in Windows PowerShell 5.1.

Reading the output

  • Account is the service's StartName from the Win32_Service class: DomainName\Username, a UPN (Username@DomainName) or .\Username for a local account.
  • Left out: LocalSystem (also written .\LocalSystem or ComputerName\LocalSystem), any account under NT AUTHORITY (such as NT AUTHORITY\LocalService and NT AUTHORITY\NetworkService) and services with no StartName.
  • Virtual accounts (NT SERVICE\ServiceName) are left out too. Pass -IncludeVirtualAccounts to list them.
  • AccountType is Local for .\Username or ComputerName\Username, Virtual for NT SERVICE, and Domain for anything else, including UPNs.
  • The script doesn't read passwords, check whether an account is still valid, or list drivers.

Sources

The Microsoft reference page for every cmdlet the script calls, plus the API and product pages behind each permission and caveat.

All scripts