Find and Disable Active Directory Users with PowerShell Faster than You can Open the GUI

In this scenario, a support request has been escalated to you because the help desk is unable to find a user account in Active Directory that needs to be disabled.

The help desk included a screenshot where they attempted to search for the user who is named “William Doe”:

finduser1

The request you received also stated that the user is in the “Sales” department so you perform a quick search for users who have a last name of “Doe” and who are also in the “Sales” department:

finduser2

Based on the results, it appears that the user’s first name is probably Scott with a middle name of William since the only result returned is “Scott W. Doe”. Now to disable his account:

finduser3

The user was located and disabled faster with PowerShell than you could have even opened the GUI.

µ

1 Comment

  1. Adrian Rodriguez

    Just for safety’s sake:

    Get-ADUser -Filter {Surname -eq ‘Doe’} | Out-GridView -OutputMode Single -Title ‘Select user to disable:’ |
    Set-ADUser -Enabled $false -PassThru

    Reply

Leave a Reply

%d bloggers like this: