Skip to content

Instantly share code, notes, and snippets.

@mikeplate
Created December 21, 2012 10:21
Show Gist options
  • Select an option

  • Save mikeplate/4351975 to your computer and use it in GitHub Desktop.

Select an option

Save mikeplate/4351975 to your computer and use it in GitHub Desktop.
Active Directory User Handling
# List all users
$filter = "(&(objectClass=user)(objectCategory=person))"
$users = ([adsiSearcher]$filter).findall()
$users | %{ $_.Properties['displayname'] }
# Sort
$users | %{ $_.Properties['displayname'] } | sort
# Filter by part of name
$users | %{ $_.Properties['displayname'] } | where { $_ -match "John" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment