Systems Administrator

Case File: The Accounts Nobody Uses

The audit asks how many accounts belong to people who left. Classify every account in a directory export as disabled, never used, stale, a password that never expires, or ok, using exact day limits and the 14-day lag of lastLogonTimestamp, and list the accounts to disable. Check the edges on exports you cannot see. The accounts are generated for you alone.

50 min

Sabi Logistics · Domain 1

The Accounts Nobody Uses

The auditor found a working account for a driver who left two years ago, and asks how many more there are

Musa Head of IT · Phone call

Musa. The auditor logged in with an account that belongs to a driver who left two years ago. Nobody had disabled it, and its password never expires. The question that I could not answer was: “How many more like it do you have?”

Here is an export of the user accounts: logon name, whether it is enabled, the date of the last logon, the date that it was created, and whether the password never expires. I want each account classified, with rules that I can explain to the auditor, and the list of accounts to disable. One more thing: the IT consultant told me that the “last logon” date is not exact. Please account for that.

The brief

What you need to know first.

  • Why the date is not exact. The attribute that most tools read, lastLogonTimestamp, is only updated when its old value is more than 14 days old, so that every logon does not create replication traffic. It can be up to 14 days behind the truth. A rule of “90 days of inactivity” must therefore use 90 + 14 = 104 days, so that you never disable somebody who logged in on day 91.
  • The classes, the first rule that applies: disabled (not enabled: leave alone); never_used (enabled, no logon at all, and created more than 30 days ago; a newer account may simply belong to somebody who has not started yet, so it is ok); stale (the last logon is more than 104 days ago); pwd_never_expires (not stale, but the password never expires); otherwise ok.
  • Dates. date.fromisoformat(...) and (today - d).days. Compare with >: exactly 104 days is not stale, 105 is; exactly 30 days is not never_used, 31 is.
  • Return {"classes": {name: class}, "to_disable": sorted names of the never_used and stale accounts}. Disabled accounts are not in to_disable.
  • Fill in classify(today, user), review(req), result and counts. The checks run review on exports that you cannot see, including every edge and an empty export.

The lab gives you the data for this case, invented and generated for you alone. Today is 2026-11-09.

Preparing your data…

On a real system

The lab modelled the rules with a script. These are the commands that you would type on the real thing.

You want toTypeWhat you get
find accounts that have not been used for 90 daysSearch-ADAccount -AccountInactive -TimeSpan 90.00:00:00 -UsersOnlyenabled and disabled user accounts that are inactive
check the last logon date of every accountGet-ADUser -Filter * -Properties LastLogonDate | Select-Object Name, LastLogonDatea date that can be up to 14 days behind the truth
disable an accountDisable-ADAccount -Identity jdoethe account can no longer sign in

Only run commands on systems that you own or have written permission to test.

🔒 The debrief unlocks when you close the case. Finish the lab above.

Write the account audit note

Write the note for the Head of IT: the classes and the exact rules, why 104 days and not 90 (the 14 day lag of lastLogonTimestamp), why never-used accounts have a grace period of 30 days, how many accounts are in each class and which are to be disabled, how to disable safely (a Disabled OU, a reason and date, a retention period, manager review, account expiry for seasonal staff), and how to keep it from coming back (service accounts and gMSA, the HR leavers list, a monthly report).

0 words

🧪 Want to practise this on your own computer? See how to set up your lab →

📝

Knowledge Check

1 of 4

Why does the stale rule use 104 days for a policy of 90 days of inactivity?

Report a problem

About: /lessons/case-the-ghost-accounts