Revision #1

You are currently reviewing an older revision of this page.
Go to current version

Various scripting and command-line methods for querying Active Directory for a list of users.

Directory Services

DSQuery User

Query a list of all users

    dsquery user

Query disabled users

    dsquery user -disabled

DSGet User

Query disabled users and list their sAMAccountNames.

    dsquery user -disabled | dsget user -samid




    $adsiSearcher = [adsisearcher]'(ObjectCategory=User)' 
    $adsiSearcher.searchroot = 'LDAP://DC=Contoso,DC=Internal' 
    $searcherResults = $adsiSearcher.findall() 

Active Directory module

Import the Windows ActiveDirectory module and retrieve a list of all users

    Import-Module ActiveDirectory
    Get-ADuser -filter *

Quest ActiveRoles snapin

Import the Quest PowerShell module and retrieve a list of all users

    Add-PSsnapin Quest.activeroles.admanagement
    Get-QADUser -SizeLimit 0
Revert to this revision