Rem PowerShell Commands to Get-User Info Get-ADUser -Filter * -Property * | Format-Table Name,SamAccountName,passwordlastset,lastlogondate -wrap Get-ADUser -Filter {Enabled -eq $true} -Properties Name,SamAccountName,LastLogon | Select-Object Name,SamAccountName,@{n='LastLogon';e={[DateTime]::FromFileTime($_.LastLogon)}} Rem PowerShell Command to Get-Computer Info Get-ADComputer -Filter * -Property * | Format-Table Name,OperatingSystem,OperatingSystemServicePack,OperatingSystemVersion,lastlogondate -Wrap Rem Save the output to a txt file using > then use excel to sort the content save back to a text text file with one computer name per line then run the following to delete old objects: Get-Content -Path C:\ComputerList.txt | Remove-ADComputer -WhatIf Rem If leaf objects exist run the following Get-Content -Path C:\ComputerList.txt | Remove-ADObject -Recursive -WhatIf Rem remove -Whatif when ready to actually delete conntent Rem To Automatically delete computers older than 365 days Search-ADAccount -AccountInactive -TimeSpan 365.00:00:00 -ComputersOnly | Remove-ADObject -Recursive -WhatIf Rem remove -Whatif when ready to actually delete conntent Search-ADAccount -AccountInactive -TimeSpan 365.00:00:00 -ComputersOnly | select-object -Property name,LastLogonDate,DistinguishedName | out-file c:\oldcomputers.txt Rem To Automatically users that have not logged on for 365 days, and have logged onto the system Search-ADAccount -AccountInactive -TimeSpan 365.00:00:00 -UsersOnly | where {$_.LastLogonDate -ne $NULL} | Remove-ADObject -Recursive -WhatIf Rem remove -Whatif when ready to actually delete conntent Search-ADAccount -AccountInactive -TimeSpan 365.00:00:00 -UsersOnly | select-object -Property name,LastLogonDate,LastLogonTimeStamp,DistinguishedName | out-file c:\oldusers.txt Find Users that have never logged in: get-aduser -f {-not ( lastlogontimestamp -like "*") -and (enabled -eq $true)} Search-ADAccount -AccountInactive -DateTime ((get-date).adddays(-365)) -UsersOnly Find users that have not changed their password in 365 days $d = [DateTime]::Today.AddDays(-365) Get-ADUser -Filter '(PasswordLastSet -lt $d) -or (LastLogonTimestamp -lt $d)' -Properties PasswordLastSet,LastLogonTimestamp | ft Name,PasswordLastSet,@{N="LastLogonTimestamp";E={[datetime]::FromFileTime($_.LastLogonTimestamp)}}