Created
May 17, 2014 16:54
-
-
Save lazywinadmin/b827b2a94e8089aa1520 to your computer and use it in GitHub Desktop.
getdomainuser_phonenumber3.ps1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Get-DomainUser | |
| { | |
| PARAM ($DisplayName,[Adsi]$SearchRoot= "LDAP://OU=Servers,OU=TEST,dc=fx,dc=lab") | |
| $Search = [adsisearcher]"(&(objectCategory=person)(objectClass=User)(displayname=$DisplayName))" | |
| $Search.searchRoot = $SearchRoot | |
| 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