Listing (and deleting) AD accounts that have been disabled for XX days
howdy,
i know can use lastlogondate find ad accounts not used we're looking bit different. when leaves our company, go in , deactivate ad account , move different ous rest of them. i'm looking find script can find accounts have been deactivated more 60 days based on date flagged inactive , not based on when logged in last.
is accomplished? if so, can point me towards tutorial or give me sample? i'm searching around haven't found exact scenario yet.
thanks!
you can tee-object writes list of adusers deleted file this:
get-aduser -searchbase "ou=employees,dc=company,dc=net" -filter {(lastlogondate -le $60days) -and (enabled -eq $false)} -properties lastlogondate, passwordlastset | tee-object -filepath c:\test.txt | remove-adobject –recursive
Windows Server > Windows PowerShell
Comments
Post a Comment