**SolarWinds make a free tool GUI for this : http://downloads.solarwinds.com/solarwinds/Release/FreeTool/SolarWinds-Freetools-MS-Mini-Utilities.zip
*****More AD Cleaup Tools
http://www.adaxes.com/blog/cleanup-active-directory-with-powershell.html
You can run these commands in a command prompt on any DC or PC With Active Directory Tools installed
Time Perioud = Weeks so for example let’s work with 6
How to find the CN or OU Path
Open Active Directory Users and Compuer , Click on View and Advanced Features
Find the OU you need to reference and Click on Properties, Attribute Editor Tab and Copy the distinguishedName
Inactive On Prem AD Computer Accounts
Find Old Disabled or Enabled Computer accounts across the whole domain older than 6 weeks
dsquery computer -inactive 6 -limit 0
Powershell Find Only Enabled Computer inactive for 3 Months
Search-ADAccount -ComputersOnly -AccountInactive -TimeSpan "90" | ?{$_.enabled -eq $True}
Find computer accounts old than 6 weeks and disable
dsquery computer -inactive 6 -limit 0 | dsmod computer -disabled yes
Find Old Computers in a Group CN e.g. if the Icon Looks like this :
dsquery computer -inactive 6 -limit 0 CN=Computers,DC=domain,DC=local (Add to stop it going further then the current folder) -scope onelevel
Find Old Computers in a Operation Unit OU e.g. if the Icon Looks like this :
dsquery computer -inactive 6 -limit 0 OU=Clients,DC=domain,DC=local (Add to stop it going further then the current folder) -scope onelevel
Query THEN DELETE computer objects which have been inactive for 8 weeks in a specific OU and name starts with PCNAME
dsquery computer "OU=Computers,OU=OUNAME,DC=domain,DC=local" -inactive 8 -name PCNAME* | dsrm -noprompt
Inactive On Prem AD User Accounts
Find Old Disable or Enabled User accounts across the whole domain older than 6 weeks
dsquery user domainroot -name * -inactive 6
Powershell Find Only Enabled User inactive for 3 Months
Search-ADAccount -UsersOnly -AccountInactive -TimeSpan "90" | ?{$_.enabled -eq $True}
Exchange Active User accounts
(Get-MailboxStatistics -Server <exchangeservername> | where {$_.LastLogonTime -gt ((get-date).AddDays(-60))}).count
Find Old User accounts across the whole domain older than 6 weeks and disable
dsquery user domainroot -name * -inactive 6 | dsmod user -disabled yes
Active User Accounts
Get-ADUser –filter * -Properties passwordLastSet,whencreated,lastlogondate,Enabled,PasswordNeverExpires | Where { ($_.passwordLastSet –eq $null –or $_.lastlogondate –gt (Get-Date).AddDays(-30)) -and ($_.Name -notlike "*svc*" -and $_.Name -notlike "*Admin*" -and $_.Name -notlike "*test*" -and $_.Name -notlike "*huonit*" -and $_.Name -notlike "*Room*" -notlike "*Mailbox*" -notlike "*Exchange*" -notlike "*Service*" -notlike "*Helpdesk*") }| Select Name
User accounts with Passwords set to never expire
get-aduser -filter * -properties Name, PasswordNeverExpires | where {
$_.passwordNeverExpires -eq "true" }