Skip to content

Instantly share code, notes, and snippets.

@lazywinadmin
Created April 21, 2014 21:25
Show Gist options
  • Save lazywinadmin/11157106 to your computer and use it in GitHub Desktop.
Save lazywinadmin/11157106 to your computer and use it in GitHub Desktop.
#http://www.lazywinadmin.com/2013/10/powershell-get-domainuser.html
function Get-DomainUser {
PARAM($DisplayName)
$Search = [adsisearcher]"(&(objectCategory=person)(objectClass=User)(displayname=$DisplayName))"
foreach ($user in $($Search.FindAll())){
New-Object -TypeName PSObject -Property @{
"DisplayName" = $user.properties.displayname -as [string]
"UserName" = $user.properties.samaccountname -as [string]
"Description" = $user.properties.description -as [string]
"TelephoneNumber" = (($user.properties.telephonenumber -as [string]).Substring(3))
}
}
}
Get-DomainUser -DisplayName "*"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment