Skip to content

Instantly share code, notes, and snippets.

@PaulStovell
Created September 8, 2015 23:19
Show Gist options
  • Save PaulStovell/17fd3b9b374b03992f59 to your computer and use it in GitHub Desktop.
Save PaulStovell/17fd3b9b374b03992f59 to your computer and use it in GitHub Desktop.
$usernameToFind = "ITARI\Administrator"
Add-Type -AssemblyName System.DirectoryServices.AccountManagement
$contextType = [System.DirectoryServices.AccountManagement.ContextType]::Domain
$context = New-Object System.DirectoryServices.AccountManagement.PrincipalContext -argumentlist ($contextType)
$user = [System.DirectoryServices.AccountManagement.UserPrincipal]::FindByIdentity($context, $usernameToFind)
Write-Output $user
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment