Search code examples
windowspowershellactive-directory

Why am I getting no output when I try to search for a deleted user in Active Directory through PowerShell?


I am trying to search Active Directory for deleted users with PowerShell, but am unable to return any results even though I have used the -IncludeDeletedObjects parameter. Here is the command that I used:

get-adobject -filter{Name -like "$user"} -includedeletedobjects -properties *

Solution

  • The answer that worked for me is the command below will list all the users that were deleted from the Active Directory if your AD recycle bin is enabled and if you have sufficient privileges on Active Directory

    Get-AdObject -Filter 'ObjectClass -eq "user" -and IsDeleted -eq $True' -IncludeDeletedObjects -Properties * | Ft Name,IsDeleted,WhenCreated