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”:


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:


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:


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


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: