Skip to content

Instantly share code, notes, and snippets.

@VertigoRay
Created August 27, 2013 18:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save VertigoRay/6357248 to your computer and use it in GitHub Desktop.
Save VertigoRay/6357248 to your computer and use it in GitHub Desktop.
$forestName = ([System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest()).Name
$ADsPath = [ADSI]"GC://$forestName"
$Search = New-Object System.DirectoryServices.DirectorySearcher($ADsPath)
$Search.Filter = "(&(objectCategory=User)(SamAccountName=user0123))"
$Search.FindAll()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment