Use this when pre-staging, moving or cleaning up computer accounts.
Computer Objects
Computer objects in AD can be pre-staged, moved, disabled or cleaned up with New-ADComputer, Move-ADObject and Get-ADComputer filtered on LastLogonTimestamp to find stale machines.
1. Computer objects: pre-stage, place in OUs, clean up stale.
2. Disable before delete.
3. OU drives GPOs.
4. LAPS attributes.
5. Report OS versions.
computer join → OU → GPO → lifecycle cleanup
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Verification path Verify boundary
The primary procedure is: Resolve one computer by objectGUID or scoped identity, record DN/SID/key attributes, perform a bounded move or attribute change in a test OU, then query again and confirm replication/target behavior. Exercise failure-oriented cases such as recreating instead of moving existing object, wrong domain/OU, duplicate names, disabled/stale object selected, replication lag, accidental SPN changes and deleting object without confirming machine lifecycle so the test covers failure cases, not only the happy path.
Step 2 Common mistakes Narrow the fault
- Pre-staging computers in the wrong OU, so GPOs differ.
- Stale computer objects never cleaned up.
Step 3 Where it fails Narrow the fault
Failure analysis for Active Directory Automation → Computer Objects should follow the path through the components: inventory/request → domain controller/session/auth → LDAP object resolution → directory write → AD replication → machine/domain behavior. Tests should include edge cases such as recreating instead of moving existing object, wrong domain/OU, duplicate names, disabled/stale object selected, replication lag, accidental SPN changes and deleting object without confirming machine lifecycle. Recovery should preserve objectGUID/SID and pre-change attributes, repair only the intended object, wait/verify replication where required, then query by stable identity from an independent directory read path.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
- Stale computers are found by LastLogonTimestamp.
- Disable before deleting.
- Pre-staging controls which OU a machine lands in.
Get-ADComputer -Filter * -Properties LastLogonDate,OperatingSystem— inventorySearch-ADAccount -AccountInactive -ComputersOnly -TimeSpan 90— stale computersMove-ADObject <dn> -TargetPath <OU>— organise
ReferenceWhy it matters1 section · depth on demand
In depth
Computer objects in AD represent domain-joined machines. Automation pre-stages them in the right OU, renames or moves them, and cleans up stale ones based on last logon and password age.
New-ADComputer -Name 'web03' -Path 'OU=Servers,DC=corp,DC=example,DC=com'
$cutoff = (Get-Date).AddDays(-90)
Get-ADComputer -Filter { LastLogonTimeStamp -lt $cutoff -and Enabled -eq $true } -Properties LastLogonTimeStamp |
Select-Object Name, @{n='LastLogon';e={[datetime]::FromFileTime($_.LastLogonTimeStamp)}}
| Practice | Reason |
|---|---|
| Disable, move, then delete later | Safe recovery window |
Use lastLogonTimestamp (replicated) | Not exact, ~14-day lag |
| Check LAPS/BitLocker keys before deletion | Recovery data is attached to the object |
ReferenceImportant terms & boundaries1 section · depth on demand
Mechanics
Computer Objects in Active Directory Automation is owned at runtime by Active Directory Domain Services and automation operating on computer security-principal objects through LDAP/PowerShell APIs. The durable intent is desired computer-account naming, OU placement, ownership/delegation, enabled state, SPN/attribute policy and lifecycle workflow. Reliable automation must carry stable identity across the path: objectGUID/SID plus distinguishedName and sAMAccountName/DNS hostname as scoped attributes. The consumer-visible target is the exact AD computer object and its security/delegation relationships, not merely the live machine with a similar hostname. The key invariants are stable object identity is preserved across rename/move, OU scope is explicit, machine-account permissions are least privilege, duplicate/stale objects are handled deliberately and replication delay is considered.
ReferenceConfiguration & state1 section · depth on demand
Lifecycle
Store and review desired computer-account naming, OU placement, ownership/delegation, enabled state, SPN/attribute policy and lifecycle workflow; pin or at least record implementation/model versions and keep environment-specific identity outside reusable logic where possible. The stable identity contract is objectGUID/SID plus distinguishedName and sAMAccountName/DNS hostname as scoped attributes.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Active Directory Automation > Computer Objects. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://learn.microsoft.com/en-us/windows-server/identity/ad-ds/manage/understand-default-user-accounts · confidence 94%Quick lookup tables
Active Directory Automation → Computer Objects · operational reference
Context-specific ownership, verification, output and failure-boundary lookup for Active Directory Automation → Computer Objects.
| Layer | Active Directory Automation → Computer Objects operational reference |
|---|---|
| Runtime/ownership | Active Directory computer-account automation · Active Directory Domain Services and automation operating on computer security-principal objects through LDAP/PowerShell APIs |
| Persistent intent | desired computer-account naming, OU placement, ownership/delegation, enabled state, SPN/attribute policy and lifecycle workflow |
| Verification | Resolve one computer by objectGUID or scoped identity, record DN/SID/key attributes, perform a bounded move or attribute change in a test OU, then query again and confirm replication/target behavior. |
| Expected interpretation | Exactly one intended computer object is mutated, stable identity remains consistent, OU/attributes match policy, and directory read-back—not local hostname alone—confirms the result. |
| Recovery boundary | preserve objectGUID/SID and pre-change attributes, repair only the intended object, wait/verify replication where required, then query by stable identity from an independent directory read path |
Deep reference
Healthy vs suspicious evidence
Output interpretation
At minimum retain domain/DC, objectGUID/SID, DN, sAMAccountName/dNSHostName, enabled state, OU, changed attributes, replication/read timestamp and operation correlation ID. The useful output makes ambiguity visible, links to the target identity from objectGUID/SID plus distinguishedName and sAMAccountName/DNS hostname as scoped attributes, and provides enough context to safely decide whether a retry is permitted.