Pcornel
Automation · Active Directory Automation

Computer Objects

Cheat sheet · https://pcornel.dk/topic.php?topic=5689

Back to the Topic

Answer

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.

Remember

  • Stale computers are found by LastLogonTimestamp.
  • Disable before deleting.
  • Pre-staging controls which OU a machine lands in.

First checks

  • Get-ADComputer -Filter * -Properties LastLogonDate,OperatingSystem — inventory
  • Search-ADAccount -AccountInactive -ComputersOnly -TimeSpan 90 — stale computers
  • Move-ADObject <dn> -TargetPath <OU> — organise

Verify in this order

computer join → OU → GPO → lifecycle cleanup

Where it usually breaks

Input/desired state → request accepted → job/task terminal status → target object read-back → effective runtime state → original workload → regression/rollback readiness.

Active Directory Automation → Computer Objects · operational reference

LayerActive Directory Automation → Computer Objects operational reference
Runtime/ownershipActive Directory computer-account automation · Active Directory Domain Services and automation operating on computer security-principal objects through LDAP/PowerShell APIs
Persistent intentdesired computer-account naming, OU placement, ownership/delegation, enabled state, SPN/attribute policy and lifecycle workflow
VerificationResolve 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 interpretationExactly 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 boundarypreserve 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

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=5689

Confirmation

Confirm action

Continue?