THE PROBLEM
Service accounts are where “temporary” becomes permanent.
Someone needs a service to access a network share, so they configure it to run as a domain account instead of a built-in identity. That works. The password is set to never expire because nobody wants a 3am outage. The person who created it leaves the company two years later. Nobody documents what the account does, and nobody can safely change the password because nobody knows what else depends on it.
Multiply that by every application your organization has deployed in the last decade.
There are three distinct problems hiding in that pile:
The outage risk. A service account password that’s never been rotated is one accidental reset away from taking down whatever it runs. Worse is the half-rotation — someone changes the password in AD, the service keeps running on its cached credential, and the failure appears three weeks later when the service restarts during a patch window. That gap between cause and symptom makes it miserable to diagnose.
The escalation path. Domain accounts with Service Principal Names can be kerberoasted — any authenticated user requests a service ticket, takes it offline, and cracks it at leisure. A service account with an SPN, a password from 2018, and membership in a privileged group is a straight line from standard user to domain admin.
The sprawl. Services running as a named domain account when they’d work perfectly well as NetworkService or a gMSA. Each one is an unnecessary credential to manage.
This week we inventory every service and scheduled task running under a non-built-in identity, across the fleet, and cross-reference against what AD says about those accounts.
THE SCRIPT
Save the script below to:
C:\Scripts\ServiceAccountAudit.ps1powershell
# Service Account & Run-As Identity Audit
# Automate & Operate — automateandoperate.com
# Email settings — update these
$from = "[email protected]"
$to = "[email protected]"
$smtpServer = "your.smtp.server"
$smtpPort = 587
$username = "[email protected]"
$password = ConvertTo-SecureString "yourpassword" -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential($username, $password)
$logFile = "C:\Logs\ServiceAccountAudit.log"
$reportFile = "C:\Logs\ServiceAccountReport.csv"
$accountSummaryFile = "C:\Logs\ServiceAccountSummary.csv"
# Machines to audit. Leave empty to auto-discover enabled servers from AD.
$computers = @()
# Built-in identities to ignore — these have no password to manage
$builtInIdentities = @(
"LocalSystem",
"NT AUTHORITY\SYSTEM",
"NT AUTHORITY\LocalService",
"NT AUTHORITY\NetworkService",
"NT AUTHORITY\LOCAL SERVICE",
"NT AUTHORITY\NETWORK SERVICE",
"LocalService",
"NetworkService",
"SYSTEM"
)
# Password age thresholds in days
$passwordWarningDays = 365
$passwordCriticalDays = 1095 # 3 years
# Privileged groups — membership by a service account is a finding
$privilegedGroups = @(
"Domain Admins",
"Enterprise Admins",
"Schema Admins",
"Administrators",
"Account Operators",
"Backup Operators",
"Server Operators"
)
# Create log folder if missing
if (-not (Test-Path "C:\Logs")) {
New-Item -ItemType Directory -Path "C:\Logs" -Force | Out-Null
}
$timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
$dateStamp = Get-Date -Format "yyyy-MM-dd"
$report = @()
$unreachable = @()
$adCache = @{}
# ---------- DISCOVER COMPUTERS ----------
if ($computers.Count -eq 0) {
try {
Import-Module ActiveDirectory -ErrorAction Stop
$computers = (Get-ADComputer -Filter {
Enabled -eq $true -and OperatingSystem -like "*Server*"
} -Properties OperatingSystem).Name | Sort-Object
Add-Content -Path $logFile -Value "$timestamp — Discovered $($computers.Count) server(s)"
} catch {
Add-Content -Path $logFile -Value "$timestamp — AD discovery failed: $_ — using localhost"
$computers = @("localhost")
}
}
# ---------- COLLECT RUN-AS IDENTITIES ----------
foreach ($computer in $computers) {
try {
$identities = Invoke-Command -ComputerName $computer -ArgumentList (,$builtInIdentities) -ScriptBlock {
param($builtIns)
$found = @()
# ---- Windows services ----
try {
$services = Get-CimInstance -ClassName Win32_Service -ErrorAction Stop
foreach ($svc in $services) {
if ($builtIns -notcontains $svc.StartName -and $svc.StartName) {
$found += [PSCustomObject]@{
ItemType = "Service"
ItemName = $svc.Name
DisplayName = $svc.DisplayName
RunAs = $svc.StartName
State = $svc.State
StartMode = $svc.StartMode
Path = $svc.PathName
}
}
}
} catch { }
# ---- Scheduled tasks ----
try {
$tasks = Get-ScheduledTask -ErrorAction Stop |
Where-Object { $_.TaskPath -notlike "\Microsoft\Windows\*" }
foreach ($task in $tasks) {
$runAs = $task.Principal.UserId
if ($builtIns -notcontains $runAs -and $runAs -and $runAs -ne "") {
$action = ($task.Actions | ForEach-Object {
if ($_.Execute) { "$($_.Execute) $($_.Arguments)".Trim() }
}) -join " | "
$found += [PSCustomObject]@{
ItemType = "ScheduledTask"
ItemName = "$($task.TaskPath)$($task.TaskName)"
DisplayName = $task.TaskName
RunAs = $runAs
State = $task.State.ToString()
StartMode = $task.Principal.RunLevel.ToString()
Path = $action
}
}
}
} catch { }
# ---- IIS application pools ----
try {
if (Get-Module -ListAvailable -Name WebAdministration) {
Import-Module WebAdministration -ErrorAction Stop
$pools = Get-ChildItem IIS:\AppPools -ErrorAction SilentlyContinue
foreach ($pool in $pools) {
if ($pool.processModel.identityType -eq "SpecificUser") {
$found += [PSCustomObject]@{
ItemType = "IISAppPool"
ItemName = $pool.Name
DisplayName = $pool.Name
RunAs = $pool.processModel.userName
State = $pool.State
StartMode = $pool.managedRuntimeVersion
Path = "IIS Application Pool"
}
}
}
}
} catch { }
return $found
} -ErrorAction Stop
foreach ($item in $identities) {
$report += [PSCustomObject]@{
Date = $dateStamp
Computer = $computer
ItemType = $item.ItemType
ItemName = $item.ItemName
DisplayName = $item.DisplayName
RunAs = $item.RunAs
State = $item.State
StartMode = $item.StartMode
Path = $item.Path
}
}
Add-Content -Path $logFile -Value "$timestamp — $computer — $($identities.Count) non-builtin run-as identit(ies)"
} catch {
$unreachable += [PSCustomObject]@{
Computer = $computer
Reason = $_.Exception.Message
}
Add-Content -Path $logFile -Value "$timestamp — $computer — ERROR: $_"
}
}
# ---------- ENRICH WITH AD DATA ----------
$uniqueAccounts = $report.RunAs | Select-Object -Unique | Where-Object { $_ }
foreach ($account in $uniqueAccounts) {
# Normalise: strip domain prefix, skip .\ local and gMSA $ suffix handling
$samName = $account
if ($account -match '\\') { $samName = ($account -split '\\')[-1] }
if ($account -match '@') { $samName = ($account -split '@')[0] }
$isLocal = $account -like ".\*" -or $account -like "$env:COMPUTERNAME\*"
$isGmsa = $samName -like "*$"
if ($isLocal) {
$adCache[$account] = [PSCustomObject]@{
Found = $false; Type = "LOCAL ACCOUNT"; Enabled = "N/A"
PasswordLastSet = "N/A"; PasswordAgeDays = "N/A"
PasswordNeverExpires = "N/A"; HasSPN = "N/A"
PrivilegedGroups = ""; LastLogon = "N/A"; Description = ""
}
continue
}
try {
$adUser = Get-ADUser -Identity $samName -Properties `
PasswordLastSet, PasswordNeverExpires, Enabled, ServicePrincipalName, `
LastLogonDate, Description, MemberOf, msDS-SupportedEncryptionTypes `
-ErrorAction Stop
$pwdAge = if ($adUser.PasswordLastSet) {
(New-TimeSpan -Start $adUser.PasswordLastSet -End (Get-Date)).Days
} else { "NEVER SET" }
# Privileged group membership, including nested
$privMember = @()
foreach ($groupDN in $adUser.MemberOf) {
try {
$g = Get-ADGroup -Identity $groupDN -ErrorAction SilentlyContinue
if ($g -and $privilegedGroups -contains $g.Name) { $privMember += $g.Name }
} catch { }
}
$adCache[$account] = [PSCustomObject]@{
Found = $true
Type = "DOMAIN USER"
Enabled = $adUser.Enabled
PasswordLastSet = if ($adUser.PasswordLastSet) { $adUser.PasswordLastSet.ToString("yyyy-MM-dd") } else { "NEVER" }
PasswordAgeDays = $pwdAge
PasswordNeverExpires = $adUser.PasswordNeverExpires
HasSPN = ($adUser.ServicePrincipalName.Count -gt 0)
PrivilegedGroups = $privMember -join "; "
LastLogon = if ($adUser.LastLogonDate) { $adUser.LastLogonDate.ToString("yyyy-MM-dd") } else { "NEVER" }
Description = $adUser.Description
}
} catch {
# Might be a gMSA rather than a standard user
if ($isGmsa) {
try {
$gmsa = Get-ADServiceAccount -Identity $samName.TrimEnd('$') -Properties PasswordLastSet -ErrorAction Stop
$adCache[$account] = [PSCustomObject]@{
Found = $true; Type = "gMSA"; Enabled = $gmsa.Enabled
PasswordLastSet = "MANAGED"; PasswordAgeDays = "MANAGED"
PasswordNeverExpires = $false; HasSPN = $false
PrivilegedGroups = ""; LastLogon = "N/A"; Description = "Group Managed Service Account"
}
continue
} catch { }
}
$adCache[$account] = [PSCustomObject]@{
Found = $false; Type = "NOT FOUND IN AD"; Enabled = "N/A"
PasswordLastSet = "N/A"; PasswordAgeDays = "N/A"
PasswordNeverExpires = "N/A"; HasSPN = "N/A"
PrivilegedGroups = ""; LastLogon = "N/A"; Description = ""
}
}
}
# ---------- BUILD PER-ACCOUNT SUMMARY ----------
$accountSummary = @()
$kerberoastable = @()
$privilegedServiceAccounts = @()
$ancientPasswords = @()
$orphaned = @()
foreach ($account in $uniqueAccounts) {
$ad = $adCache[$account]
$usages = $report | Where-Object { $_.RunAs -eq $account }
$machines = ($usages.Computer | Select-Object -Unique)
$flags = @()
if ($ad.Type -eq "NOT FOUND IN AD") {
$flags += "ACCOUNT NOT FOUND IN AD"
}
if ($ad.Found -and $ad.Type -eq "DOMAIN USER") {
if ($ad.Enabled -eq $false) { $flags += "ACCOUNT DISABLED BUT STILL CONFIGURED" }
if ($ad.PasswordAgeDays -ne "NEVER SET" -and $ad.PasswordAgeDays -ne "N/A") {
if ([int]$ad.PasswordAgeDays -ge $passwordCriticalDays) {
$flags += "PASSWORD $($ad.PasswordAgeDays) DAYS OLD"
} elseif ([int]$ad.PasswordAgeDays -ge $passwordWarningDays) {
$flags += "PASSWORD AGING ($($ad.PasswordAgeDays) days)"
}
}
if ($ad.HasSPN -eq $true) {
$flags += "HAS SPN (kerberoastable)"
}
if ($ad.PasswordNeverExpires -eq $true) {
$flags += "PASSWORD NEVER EXPIRES"
}
if ($ad.PrivilegedGroups) {
$flags += "PRIVILEGED: $($ad.PrivilegedGroups)"
}
if ([string]::IsNullOrWhiteSpace($ad.Description)) {
$flags += "NO DESCRIPTION (undocumented)"
}
}
# The dangerous combination
if ($ad.HasSPN -eq $true -and $ad.PasswordAgeDays -ne "N/A" -and
$ad.PasswordAgeDays -ne "NEVER SET" -and [int]$ad.PasswordAgeDays -ge $passwordWarningDays) {
$kerberoastable += [PSCustomObject]@{
Account = $account
PasswordAge = $ad.PasswordAgeDays
Privileged = $ad.PrivilegedGroups
MachineCount = $machines.Count
Machines = ($machines | Select-Object -First 5) -join ", "
}
}
if ($ad.PrivilegedGroups) {
$privilegedServiceAccounts += [PSCustomObject]@{
Account = $account
Groups = $ad.PrivilegedGroups
PasswordAge = $ad.PasswordAgeDays
MachineCount = $machines.Count
UsedFor = ($usages | Select-Object -First 3 | ForEach-Object { "$($_.ItemType):$($_.DisplayName)" }) -join "; "
}
}
if ($ad.PasswordAgeDays -ne "N/A" -and $ad.PasswordAgeDays -ne "NEVER SET" -and
$ad.PasswordAgeDays -ne "MANAGED" -and [int]$ad.PasswordAgeDays -ge $passwordCriticalDays) {
$ancientPasswords += [PSCustomObject]@{
Account = $account
PasswordAge = $ad.PasswordAgeDays
MachineCount = $machines.Count
}
}
if ($ad.Type -eq "NOT FOUND IN AD" -or $ad.Enabled -eq $false) {
$orphaned += [PSCustomObject]@{
Account = $account
Reason = $ad.Type
MachineCount = $machines.Count
UsedFor = ($usages | Select-Object -First 3 | ForEach-Object { "$($_.Computer):$($_.DisplayName)" }) -join "; "
}
}
$status = if ($flags -match "NOT FOUND IN AD|DISABLED BUT STILL|PRIVILEGED:|HAS SPN") {
"CRITICAL"
} elseif ($flags.Count -gt 0) {
"WARNING"
} else {
"OK"
}
$accountSummary += [PSCustomObject]@{
Date = $dateStamp
Account = $account
Type = $ad.Type
Enabled = $ad.Enabled
PasswordLastSet = $ad.PasswordLastSet
PasswordAgeDays = $ad.PasswordAgeDays
PasswordNeverExpires = $ad.PasswordNeverExpires
HasSPN = $ad.HasSPN
PrivilegedGroups = $ad.PrivilegedGroups
Description = $ad.Description
MachineCount = $machines.Count
UsageCount = $usages.Count
Machines = ($machines | Select-Object -First 10) -join ", "
Status = $status
Flags = if ($flags.Count -gt 0) { $flags -join "; " } else { "OK" }
}
}
# ---------- EXPORT ----------
$report | Sort-Object Computer, ItemType | Export-Csv -Path $reportFile -NoTypeInformation
$accountSummary | Sort-Object Status, Account | Export-Csv -Path $accountSummaryFile -NoTypeInformation
# ---------- BUILD EMAIL ----------
$criticalAccounts = $accountSummary | Where-Object { $_.Status -eq "CRITICAL" }
$warningAccounts = $accountSummary | Where-Object { $_.Status -eq "WARNING" }
$gmsaCount = ($accountSummary | Where-Object { $_.Type -eq "gMSA" }).Count
$emailBody = "Service Account Audit — $timestamp`n"
$emailBody += "Machines audited: $($computers.Count) | Unreachable: $($unreachable.Count)`n"
$emailBody += "Services / tasks / app pools with custom identity: $($report.Count)`n"
$emailBody += "Distinct accounts in use: $($uniqueAccounts.Count) (gMSA: $gmsaCount)`n`n"
$emailBody += "CRITICAL: $($criticalAccounts.Count) | WARNING: $($warningAccounts.Count)`n"
$emailBody += "Kerberoastable with old password: $($kerberoastable.Count)`n"
$emailBody += "Privileged service accounts: $($privilegedServiceAccounts.Count)`n"
$emailBody += "Orphaned / disabled still configured: $($orphaned.Count)`n`n"
if ($kerberoastable.Count -gt 0) {
$emailBody += "*** KERBEROASTABLE — SPN + OLD PASSWORD ***`n"
$emailBody += "Any authenticated user can request these tickets and crack them offline.`n"
$emailBody += "=" * 60 + "`n"
foreach ($k in ($kerberoastable | Sort-Object { [int]$_.PasswordAge } -Descending)) {
$emailBody += "Account: $($k.Account)`n"
$emailBody += "Password age: $($k.PasswordAge) days`n"
if ($k.Privileged) { $emailBody += "PRIVILEGED: $($k.Privileged)`n" }
$emailBody += "Used on: $($k.MachineCount) machine(s) — $($k.Machines)`n"
$emailBody += "-" * 40 + "`n"
}
$emailBody += "`n"
}
if ($privilegedServiceAccounts.Count -gt 0) {
$emailBody += "*** SERVICE ACCOUNTS IN PRIVILEGED GROUPS ***`n"
$emailBody += "=" * 60 + "`n"
foreach ($p in $privilegedServiceAccounts) {
$emailBody += "Account: $($p.Account)`n"
$emailBody += "Groups: $($p.Groups)`n"
$emailBody += "Password age: $($p.PasswordAge) days`n"
$emailBody += "Used on: $($p.MachineCount) machine(s)`n"
$emailBody += "Running: $($p.UsedFor)`n"
$emailBody += "-" * 40 + "`n"
}
$emailBody += "`n"
}
if ($orphaned.Count -gt 0) {
$emailBody += "ORPHANED OR DISABLED ACCOUNTS STILL CONFIGURED:`n"
$emailBody += "=" * 60 + "`n"
foreach ($o in $orphaned) {
$emailBody += "$($o.Account) — $($o.Reason) — $($o.MachineCount) machine(s)`n"
$emailBody += " $($o.UsedFor)`n"
}
$emailBody += "`n"
}
if ($ancientPasswords.Count -gt 0) {
$emailBody += "PASSWORDS OVER $passwordCriticalDays DAYS OLD:`n"
$emailBody += "=" * 60 + "`n"
foreach ($a in ($ancientPasswords | Sort-Object { [int]$_.PasswordAge } -Descending)) {
$emailBody += "$($a.Account) — $($a.PasswordAge) days — on $($a.MachineCount) machine(s)`n"
}
$emailBody += "`n"
}
if ($warningAccounts.Count -gt 0) {
$emailBody += "WARNINGS:`n"
$emailBody += "=" * 60 + "`n"
foreach ($w in $warningAccounts) {
$emailBody += "$($w.Account) — $($w.Flags)`n"
}
$emailBody += "`n"
}
$emailBody += "ALL SERVICE ACCOUNTS IN USE:`n"
$emailBody += "=" * 60 + "`n"
foreach ($a in ($accountSummary | Sort-Object MachineCount -Descending)) {
$emailBody += "[$($a.Status)] $($a.Account) — $($a.Type) — $($a.UsageCount) usage(s) on $($a.MachineCount) machine(s)`n"
if ($a.Description) { $emailBody += " $($a.Description)`n" }
}
if ($unreachable.Count -gt 0) {
$emailBody += "`nUNREACHABLE:`n"
$emailBody += "=" * 60 + "`n"
foreach ($u in $unreachable) { $emailBody += "$($u.Computer) — $($u.Reason)`n" }
}
$emailBody += "`nDetailed usage: $reportFile`n"
$emailBody += "Account summary: $accountSummaryFile`n`n"
$emailBody += "Useful commands:`n"
$emailBody += " Get-CimInstance Win32_Service | Where-Object { `$_.StartName -notlike 'NT AUTHORITY*' }`n"
$emailBody += " setspn -L <account> List SPNs on an account`n"
$emailBody += " Get-ADServiceAccount -Filter * List existing gMSAs`n`n"
$emailBody += "Automate & Operate — automateandoperate.com"
$subject = if ($kerberoastable.Count -gt 0) {
"SERVICE ACCOUNT CRITICAL: $($kerberoastable.Count) kerberoastable account(s) with aged passwords"
} elseif ($privilegedServiceAccounts.Count -gt 0) {
"Service Account Audit — $($privilegedServiceAccounts.Count) privileged service account(s)"
} elseif ($criticalAccounts.Count -gt 0) {
"Service Account Audit — $($criticalAccounts.Count) critical finding(s)"
} else {
"Service Account Audit — $($uniqueAccounts.Count) account(s), no critical findings"
}
Send-MailMessage `
-From $from -To $to `
-Subject $subject `
-Body $emailBody `
-SmtpServer $smtpServer -Port $smtpPort `
-UseSsl -Credential $credentialUpdate these lines:
$from/$to/$username/$password— your email details$smtpServer— your SMTP server (e.g.smtp.office365.com)$computers— leave empty to auto-discover servers from AD$passwordWarningDays/$passwordCriticalDays— 365 and 1095 are reasonable
Requirements: RSAT ActiveDirectory module, PowerShell remoting, admin rights on targets. The IIS section only runs where the WebAdministration module exists, so it silently skips non-IIS servers.
READ THE KERBEROASTABLE SECTION FIRST
Everything else in this report is housekeeping. That first section is a live attack path.
Here’s why it matters more than it sounds. Any authenticated domain user — not an admin, any user — can request a Kerberos service ticket for an account that has an SPN. That ticket is encrypted with a key derived from the account’s password. The attacker takes it offline and brute-forces it with no rate limiting, no lockout, and nothing in your logs that looks unusual, because requesting service tickets is what Kerberos does all day.
A password set in 2019 was chosen under 2019’s standards, by a human, probably following a pattern. Modern hardware chews through that.
If the account is also in a privileged group, the chain is: standard user → service ticket → offline crack → domain admin. No exploit, no malware, no privilege escalation bug. Just a password that was set once and never changed.
The script flags the combination specifically — SPN plus password older than a year — because either one alone is common and mostly fine. Together they’re the finding.
The fix is a long random password, 25+ characters, since nobody types it interactively anyway. Or move the account to a gMSA and stop managing the password entirely.
gMSAs ARE THE ACTUAL ANSWER
Group Managed Service Accounts solve this category of problem properly. Windows rotates the password automatically every 30 days, the password is 240 characters of random, and nobody ever knows it or needs to.
They’re not new — Server 2012 — and they’re underused mostly because the existing accounts work and nobody wants to touch them.
Creating one:
powershell
# One-time per forest, if not already done
Add-KdsRootKey -EffectiveTime ((Get-Date).AddHours(-10))
# Create the gMSA and authorize which machines can use it
New-ADServiceAccount -Name "gmsa_sqlbackup" `
-DNSHostName "gmsa_sqlbackup.yourdomain.com" `
-PrincipalsAllowedToRetrieveManagedPassword "SQL-Servers-Group"
# On each server that will use it
Install-ADServiceAccount -Identity "gmsa_sqlbackup"
Test-ADServiceAccount -Identity "gmsa_sqlbackup"Then set the service to run as DOMAIN\gmsa_sqlbackup$ with a blank password — the trailing $ matters, and the blank password is correct, not an oversight.
The catch: not every application supports them. SQL Server does, IIS app pools do, most scheduled tasks do. Some older third-party services don’t. Test before committing.
The script reports gMSAs separately so you can see your coverage, and so a correctly-configured gMSA doesn’t show up as a finding.
THE ORPHANED SECTION
Accounts configured on a service but missing from AD, or disabled and still configured.
A disabled account still set on a running service is a time bomb — the service is running on a cached token and will fail on next restart. That restart might be during a patch window three weeks from now, which means the outage and the cause are separated by three weeks of other changes.
An account that doesn’t exist in AD at all usually means a leftover from a domain migration, or a typo’d account name on a service that’s been failing to start since someone configured it.
Both are cheap to fix and expensive to discover during an incident.
THE “NO DESCRIPTION” FLAG
Soft finding, but it’s the one that compounds.
Every service account with an empty Description field is a future archaeology project. Somebody will eventually need to know what svc_app01 does, and the answer will involve tracing services across servers and asking people who’ve been there longest.
Fill them in as you work through the report:
powershell
Set-ADUser -Identity "svc_backup" -Description "Veeam B&R service account — owner: Infrastructure team — created 2021 for backup proxy auth"Owner, purpose, and roughly when. Thirty seconds now, saves an afternoon later.
SETTING UP TASK SCHEDULER
Press Windows key → type Task Scheduler → open it
Click “Create Basic Task” → name it
Service Account AuditTrigger: Monthly → 1st of the month → 7:00am
Action: Start a program
Program:
powershell.exeArguments:
-ExecutionPolicy Bypass -File "C:\Scripts\ServiceAccountAudit.ps1"Click Next → Finish
Under Properties → General, check “Run with highest privileges”.
Monthly is right here. Service account configuration changes rarely, the report takes real effort to action, and a weekly email you stop reading is worse than a monthly one you act on.
This script is heavier than most in this series — it queries services, tasks, and IIS on every machine, then does AD lookups per account. On a large fleet, expect several minutes.
TEST IT
Run as administrator:
powershell
powershell.exe -ExecutionPolicy Bypass -File "C:\Scripts\ServiceAccountAudit.ps1"Check what one machine returns first:
powershell
Get-CimInstance Win32_Service |
Where-Object { $_.StartName -notlike "NT AUTHORITY*" -and $_.StartName -ne "LocalSystem" } |
Select-Object Name, StartName, State, StartModeTo see the SPN situation across your domain directly:
powershell
Get-ADUser -Filter { ServicePrincipalName -like "*" } -Properties ServicePrincipalName, PasswordLastSet |
Select-Object Name, PasswordLastSet, @{N='SPNs';E={$_.ServicePrincipalName -join '; '}} |
Sort-Object PasswordLastSetThat one-liner on its own is worth running today. The accounts at the top of that list are your exposure.
ROTATING A SERVICE ACCOUNT PASSWORD WITHOUT AN OUTAGE
The reason these passwords never get changed is that changing them breaks things. Here’s the order that doesn’t:
Find every usage first. The CSV gives you this — that’s the main reason it exists. An account used on eleven machines needs eleven updates, and missing one means a service that fails on next restart.
Change the password in AD. Services keep running on their cached credential, so nothing breaks immediately. This is your window.
Update every service, task and app pool to the new password. Services need a restart to pick it up.
Restart each service deliberately, one at a time, confirming each comes back. Don’t wait for a reboot to find out.
Updating a service’s credentials remotely:
powershell
$newPw = Read-Host -AsSecureString
Invoke-Command -ComputerName "SERVER01" -ScriptBlock {
param($pw)
$svc = Get-CimInstance Win32_Service -Filter "Name='YourService'"
$plainPw = [Runtime.InteropServices.Marshal]::PtrToStringAuto(
[Runtime.InteropServices.Marshal]::SecureStringToBSTR($pw))
$svc | Invoke-CimMethod -MethodName Change -Arguments @{ StartPassword = $plainPw }
Restart-Service -Name "YourService"
} -ArgumentList $newPwDo the highest-risk account first — the kerberoastable privileged one — and do it on a day you’ve got time to fix what breaks.
WHY THIS MATTERS
Service accounts sit in the gap between security and operations, which is exactly why they rot. Security teams see an aged credential and want it rotated. Ops teams know rotating it will break something they can’t fully predict. Nobody owns the problem, so it persists.
The thing that breaks the deadlock is an inventory. Once you know that svc_sqlagent is used by four services on three servers and nothing else, rotating it stops being a gamble and becomes a fifteen-minute task.
And the kerberoastable finding converts an abstract risk into a named account with a specific password age. That’s the version that gets prioritised.
THIS WEEK’S ACTION
Run it once across your servers. Read only the kerberoastable section. If anything appears there with a privileged group attached, that’s your Monday — a long random password on that one account closes a direct path to domain admin.
Reply to this email if you hit any issues — I read every reply.
Automate & Operate — automateandoperate.com
Meet your team’s new overachiever.
Laptops built for workday breakthroughs.
Stay productive, grow your business. With built-in intelligence on the Dell Pro laptop powered by Intel® Core™ Ultra with Intel vPro®.

