Skip to content

Instantly share code, notes, and snippets.

@lazywinadmin
Created May 6, 2014 17:09
Show Gist options
  • Save lazywinadmin/38f8fe06e420d95acffa to your computer and use it in GitHub Desktop.
Save lazywinadmin/38f8fe06e420d95acffa 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(4))
}
}
}
Get-DomainUser -DisplayName "*"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment