← All articles

How to Track Service Account Expiry in Active Directory

How to Track Service Account Expiry in Active Directory

Last Updated: December 4, 2026

Quick Summary

You track service account expiry by recording each account's provider expiry date, internal rotation deadline and owner in one shared record, then reviewing it on a fixed schedule. Treat service account expiry as a metadata problem: track the deadline and the person accountable, not the secret value.

  • Active Directory stores account expiry in the AccountExpires attribute and the last password change in PasswordLastSet.
  • An inventory template needs nine fields, including owner, provider expiry date, next deadline and dependencies.
  • Set the warning window from the coordination work a rotation needs, not from habit.
  • Before rotating, confirm dependent services and tasks, then restart or re-run them and check success.
  • A missing deadline should trigger a review rather than be left blank.

Table of Contents

How do I track service account expiry?

You track service account expiry by recording each account's provider expiry date, internal rotation deadline and owner in one shared record, then reviewing it on a fixed schedule.

A service account is a non-human identity a system uses to authenticate, such as a Windows service logon account or a scheduled task identity (Non-human identities in Microsoft Defender - Microsoft Defender XDR). Its expiry date is a property of the directory object; its rotation deadline is a policy decision your team makes.

Why expiry tracking fails without an owner

Most teams can find an expired account after something breaks. Fewer can name the owner before it does.

  • The spreadsheet has a "last rotated" cell. One cell hides the fact that an older key for the same account is still active.
  • The calendar reminder belongs to one person. When that person leaves, the reminder leaves with them.
  • A rotation request was logged, but nobody confirmed the dependent workload still runs.

A scheduled task, a rotation request or a new secret version does not by itself prove the work finished. Record the evidence source, the completion date, and confirmation that dependent workloads still run.

Using Active Directory account expiration date PowerShell queries

Active Directory stores an account's expiry in the AccountExpires attribute and the last password change in PasswordLastSet. A PowerShell query against both gives you a starting list, raw material, not your inventory.

Flowchart mapping the service account expiry process via PowerShell queries, dependency checks, and CSV exports.
Flowchart mapping the service account expiry process via PowerShell queries, dependency checks, and CSV exports.

Prerequisites

  • The ActiveDirectory PowerShell module, available with RSAT on a management workstation.
  • A read-only account with permission to query user objects. Do not run inventory queries with a privileged admin account.
  • A reachable domain controller. Point queries at a specific one to keep results consistent.

A basic read-only query

The following is illustrative pseudocode, not a tested script. Adjust the filter and properties to your environment.

Get-ADUser -Filter 'Name -like "svc-*"' -Properties AccountExpires, PasswordLastSet, LastLogonTimestamp, Enabled |
    Select-Object Name, SamAccountName, Enabled, AccountExpires, PasswordLastSet, LastLogonTimestamp |
    Export-Csv -Path .\svc-account-expiry.csv -NoTypeInformation
Two things to watch for.

**Watch out:** `AccountExpires` uses a large integer format where certain values mean "never expires." A naive conversion will produce nonsense dates. Check the raw value before you trust the formatted one.

**Watch out:** Do not write credentials, connection strings or secret values into your query output or CSV. Keep the export to metadata only.

### Finding where the account is actually used

An expiry date tells you when the account dies. It does not tell you what dies with it. Check Windows services running under a domain account and scheduled tasks with a stored credential, recording the service name, host and task path. For each hit, add the dependency to the account's record, this is the field that turns a list of dates into something you can act on.

### Checking activity and last logon

**LastLogonTimestamp** is replicated across domain controllers but is not precise ([(MS-ADLS): Attribute lastLogonTimestamp](https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adls/ba6d87f9-7023-4ccd-9d0e-dd7b53865db5)). Use it to spot stale accounts, not to prove an account is in use. An account with no recent logon may still be critical if it runs quarterly. A stale account with an owner is a review item, not an automatic deletion.

## Building a service account inventory template

An inventory template is a fixed set of columns that every service account record fills in. If you would rather not build the columns from scratch, the [free credential inventory template](https://keyguardrail.com/resources/credential-inventory-template) gives you a ready starting point.

Use this checklist:

- [ ] **Account name** and the credential record it maps to
- [ ] **Provider** and environment, such as production or staging
- [ ] **Credential type**, such as password, key or certificate
- [ ] **Owner**, a named person or team
- [ ] **Provider expiry date**
- [ ] **Internal rotation interval**
- [ ] **Next deadline**, the earlier of provider expiry and the rotation policy
- [ ] **Dependencies**, the services and tasks that use it
- [ ] **Last confirmed rotation**, with the evidence source

Two structural rules make the template hold up. First, separate the account from its credentials: one service account can have several keys with different expiry dates, and a single "last rotated" cell cannot represent that. Second, a missing deadline should trigger a review, not be left blank, a blank field is a decision nobody made.

For guidance on recording purpose and owner per account, see [how to document service account purpose](/blog/how-to-document-service-account-purpose). A consistent [service account naming convention](/blog/service-account-naming-conventions) makes ownership and expiry readable at a glance.

| Field | Example placeholder | Why it matters |
| --- | --- | --- |
| Account name | `svc-reporting-prod` | Ties the record to the directory object |
| Owner | `platform-team` | Names who acts when the deadline nears |
| Provider expiry | `2026-09-30` | Hard limit set by the provider |
| Rotation interval | `90 days` | Policy your team controls |
| Next deadline | `2026-08-15` | Earlier of the two above |
| Dependencies | `nightly-export-task` | What breaks if the account dies |

## Setting service account credential expiry reminders and a service account rotation schedule

A reminder is only useful if it fires before the deadline and reaches someone who can act. A rotation schedule is only useful if the interval fits the workload.

### Choosing a warning window

Set the warning window from the work, not from habit. A credential that takes a week of coordination needs a longer lead than one rotated in an afternoon. Many teams use a two-stage reminder: an early notice for planning and a later one for escalation. Test delivery with a test email after you enable reminders, a reminder that lands in an unmonitored inbox is the same as no reminder.

### Building the rotation schedule

Map each credential type to an interval. Shorter intervals suit broadly scoped keys; longer ones suit narrow, well-monitored credentials. The [30/60/90-day rotation policy guide](/blog/credential-rotation-30-60-90-day-policy) sets out the interval framework in more detail.

For each rotation, record the completion date, the evidence source (such as a provider audit entry), and confirmation that dependent workloads still run. Describe team-reported completion as reported work, not as independent proof of change.

If you are comparing reminder options, [credential expiration reminder tools for IT teams](/blog/credential-expiration-reminder-tools-for-it-teams) covers workflows for tracking deadlines. For teams running scripts and CI pipelines, [PowerShell secrets management](/blog/powershell-secrets-management-devops) covers keeping secret values out of scripts.

### Safe remediation

Before rotating, confirm the dependent services and tasks. After rotating, restart the service or re-run the task and check it succeeds. If it fails, the old credential may still be needed as a rollback. Keep the rollback window short and documented.

KeyGuardRail holds the metadata for this workflow: owner, expiry, rotation interval, lifecycle reminders and audit history. The secret values stay in your existing vault or provider. You rotate in the provider, then record the work in KeyGuardRail. If you want to see how the metadata fields and reminders fit together, [credential lifecycle monitoring](https://keyguardrail.com/getting-started) walks through the setup, and you can [create a free workspace](https://keyguardrail.com/signup) to try it with your own inventory.
<section style="margin:3rem 0 2rem 0;" itemscope itemtype="https://schema.org/FAQPage"><h2 style="font-weight:700; margin:0 0 4px 0;">Frequently Asked Questions</h2><div style="padding:20px 0; border-bottom:1px solid #e5e7eb;" itemscope itemprop="mainEntity" itemtype="https://schema.org/Question"><h3 style="font-weight:600; margin:0 0 8px 0;" itemprop="name">How can I check a service account&#039;s expiry date?</h3><div style="line-height:1.7;" itemscope itemprop="acceptedAnswer" itemtype="https://schema.org/Answer"><p itemprop="text" style="margin:0;">Query Active Directory directly rather than trusting a spreadsheet. In PowerShell, run Get-ADUser -Identity &lt;account&gt; -Properties AccountExpires, PasswordLastSet and read the AccountExpires value, converting it from FILETIME if needed. A null or 0 value often means the account never expires, which deserves its own review. For managed service accounts, check the msDS-ManagedPasswordInterval and related attributes. Record the provider expiry and your internal rotation deadline separately, because the next deadline is whichever comes first.</p></div></div><div style="padding:20px 0; border-bottom:1px solid #e5e7eb;" itemscope itemprop="mainEntity" itemtype="https://schema.org/Question"><h3 style="font-weight:600; margin:0 0 8px 0;" itemprop="name">What should a service account inventory include?</h3><div style="line-height:1.7;" itemscope itemprop="acceptedAnswer" itemtype="https://schema.org/Answer"><p itemprop="text" style="margin:0;">At minimum record the account name, provider or domain, credential type, environment, accountable owner, provider expiry date, internal rotation deadline, last confirmed rotation date, and the evidence source for that rotation. Keep the account separate from its individual credentials, since one service account can hold several keys with different expiry dates. A missing deadline should trigger a review, not silence. KeyGuardRail&#039;s free credential inventory template captures these fields without storing secret values.</p></div></div><div style="padding:20px 0; border-bottom:1px solid #e5e7eb;" itemscope itemprop="mainEntity" itemtype="https://schema.org/Question"><h3 style="font-weight:600; margin:0 0 8px 0;" itemprop="name">How far in advance should teams plan credential rotation?</h3><div style="line-height:1.7;" itemscope itemprop="acceptedAnswer" itemtype="https://schema.org/Answer"><p itemprop="text" style="margin:0;">Plan from the earlier of provider expiry and your own rotation policy, then give dependent workloads enough time to be verified before the deadline. A common mistake is treating a scheduled task, a rotation request, or a new secret version as proof the work finished. Record the completion date, the evidence source, and verification that dependent services still run. Warning windows should be long enough to schedule the change and test it, and reminders should be confirmed with a test email before you rely on them.</p></div></div></section>
GoogleAdd keyguardrail.com as a preferred source on Google →