none
Powershell to get users from specific ou that have been modified/disabled 6 months ago. RRS feed

  • Question

  • Hi,

    I'm trying to figure out a script that gives a list of usernames in a specific OU that have been modified 6 months ago from the current date.  (i.e. User alison was disabled on July 7, 2014, that user should be in the list.  User Joe was modified on April 1, 2015, he shouldn't be in that list.)

    Here's what I have now, but it doesn't seem to work right..

    $date = (Get-Date).AddMonths(-6)
    Get-ADUser -SearchBase 'ou=DisabledAccounts,DC=xxx,DC=xxx' -Filter {Modified -gt $date} | select name 

    I know I can then export it to csv, but just want the correct output.. basically we want to get rid of disabled accounts that our HRIS system moves to this OU after 6 months (i.e. staff that are no longer here).

    Any help would be greatly appreciated!

    Thanks


    • Edited by CaseyJPSD Wednesday, April 8, 2015 3:23 PM
    Wednesday, April 8, 2015 3:23 PM

Answers