14 Oct 2011 @ 9:48 AM 

Earlier today I’ve posted about cleaning up your Active Directory before starting a migration by removing old computer accounts. Next would be removing old user accounts.
Normally, when a user leaves the company either the user account is removed, or disabled.

If it is removed, the issue stated earlier isn’t applicable. But when a user leaves, company policy states that the account must be kept at least 6 months and it must only be disabled.
So, only accounts that are disabled and haven’t been used for more than 6 months must be found.

To find old user accounts:
Search-ADAccount -accountdisabled | where {$_.lastlogondate -lt (get-date).addmonths(-6)} | FT Name,LastLogonDate

And to delete old user accounts:
Search-ADAccount -accountdisabled | where {$_.lastlogondate -lt (get-date).addmonths(-6)} | Remove-ADUser

Post to Twitter

Posted By: Jeff Wouters
Last Edit: 23 Apr 2012 @ 06:21 AM

EmailPermalink
Tags



Get Adobe Flash player
 Last 50 Posts
 Back
Change Theme...
  • Users » 1
  • Posts/Pages » 164
  • Comments » 150
Change Theme...
  • VoidVoid « Default
  • LifeLife
  • EarthEarth
  • WindWind
  • WaterWater
  • FireFire
  • LightLight

About



    No Child Pages.

Contact



    No Child Pages.