An function to search Active Direcgory on user.
If you wonder what info you can get….
1 |
get-aduser "username" -properties * |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
<# .Synopsis Get Userinfo based on displayname .DESCRIPTION Get info about Lastname, Givenname, UPN and mailnickname, description .EXAMPLE get-userinfo -displayname Damberg .EXAMPLE get-userinfo dam #> function get-Userinfo { [CmdletBinding()] [Alias()] [OutputType([int])] Param ( # Param1 help description [Parameter(Mandatory=$true, ValueFromPipelineByPropertyName=$true, Position=0)] $displayname ) Begin { #add wildcards to search $displaynameFix ="*$displayname*" } Process { get-aduser -filter {displayname -like $displaynamefix } -SearchBase 'OU=Employee,OU=Users,OU=department,DC=company,DC=com' -Properties Surname, givenname, UserPrincipalName, mailnickname, description | select surname, givenname, UserPrincipalName, mailnickname, description | FT -AutoSize } End { } } |