Inactive computer account clean up


                         As workstations get added and removed to AD, computer accounts become needs to be cleaned up so they can be used for new computers. The following Powershell code retrieves all computers that either has not logged into AD for more than 90 days or never logged in and exports into a file.

Get-QADComputer -SizeLimit 0 -IncludedProperties LastLogonTimeStamp -SearchRoot 'ad.umbc.edu/Dept' |
where { ($_.AccountIsDisabled -eq $false) -and (($_.LastLogonTimeStamp -eq $null) -or ((((get-date) - $_.LastLogonTimeStamp).Days) -gt 90)) } |
Select-Object Name, ParentContainer, DN | Sort -Property ParentContainer| Export-Csv <file>

Comments

Popular posts from this blog

AD LDS – Syncronizing AD LDS with Active Directory

DNS Scavenging.

The role of VMware Integrated Containers in real life scenario - PART 3