Why use this template?
Use this free PowerShell script when you need to find enabled computers that have not logged on recently. It is generated locally and can be reviewed before you run it yourself in your own PowerShell session.
The template uses ActiveDirectory and requires Directory read access. Output: CSV report. Level: Intermediate. Action: Read-only. Risk: Low.
Review before running
The script is generated in your browser. Read it before you run it, and test it outside production first. “Read-only” describes the script itself; anything you add around it can still change data.
Generate the script
- Open the template in the PowerShell Builder.
- Enter the requested values and review the module, permissions, output and risk.
- Generate the script, read it carefully, and test it outside production before use.
The script is generated locally in your browser. Nothing needs to be uploaded to Opselith.
Generate Find stale AD computers →How to use this result
Use this report as a review queue for enabled Active Directory computer accounts with no recent replicated logon timestamp, not as an automatic deletion list.
When this helps
- Prepare a stale-computer review before disabling or removing old computer accounts.
- Find enabled computer objects with a blank or older LastLogonDate than your chosen threshold.
- Create a repeatable CSV snapshot for workstation and server account hygiene reviews.
How to read the result
- LastLogonDate is based on the replicated lastLogonTimestamp value, so it is intentionally approximate rather than a precise last-use timestamp.
- A blank LastLogonDate is included as a review candidate. It is not proof that the computer is unused or safe to remove.
Things to check
- Verify servers, infrequently connected devices, lab systems and other known exceptions before changing any computer account.
- Choose a threshold that fits your environment and compare the result with device-management or ownership evidence when available.
What to do next: Review the oldest candidates first, confirm device ownership and purpose, and only then use a separate approved process for any disable or removal action.
Related tasks
Official references