Automation · Active Directory Automation
Computer Objects
Cheat sheet · https://pcornel.dk/topic.php?topic=5689
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— inventorySearch-ADAccount -AccountInactive -ComputersOnly -TimeSpan 90— stale computersMove-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
| 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 |
Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=5689