header1   header
header
header Register : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
Get AD info uisng username
Last Post 13 Jun 2011 07:49 AM by kdn242. 6 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
kdn242User is Offline
New Member
New Member
Posts:6
Avatar

--
10 Jun 2011 04:05 AM
    I'm a newbie, and I want to create a script that could allow me to pull out the information of the user in AD using the username. I would be nice if I could create a box to put the username in.

    I don't get the part how to connect to the Active directory, and how could you create a variable to take the usename and looking for the info in Active Directory.

    Any advice or suggestion is highly apprieciated.

    Thank you very much for you time!

    KDN
    kdn242User is Offline
    New Member
    New Member
    Posts:6
    Avatar

    --
    10 Jun 2011 05:18 AM
    I got this error message when I try to use your command.!
    PS C:\Users\m1kdn00> $user= get-aduser"m1kdn00"
    The term 'get-aduserm1kdn00' is not recognized as the name of a cmdlet, function, script file, or operable program. Che
    ck the spelling of the name, or if a path was included, verify that the path is correct and try again.
    At line:1 char:27
    + $user= get-aduser"m1kdn00" <<<<
    + CategoryInfo : ObjectNotFound: (get-aduserm1kdn00:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    uSlackrUser is Offline
    New Member
    New Member
    Posts:68
    Avatar

    --
    10 Jun 2011 05:20 AM
    getting a user is straightforward. " >$user = get-aduser "myusername" " will do it. Now $user contain the AD user object for you. After that " >$user " will show the AD information fir the user now stored int e the variable $user.

    In general I would start with making things work at the command-line then think about a more complicated script
    \\uSlackr
    uSlackrUser is Offline
    New Member
    New Member
    Posts:68
    Avatar

    --
    10 Jun 2011 05:48 AM
    Posted By kdn242 on 10 Jun 2011 06:18 AM
    I got this error message when I try to use your command.!
    PS C:\Users\m1kdn00> $user= get-aduser"m1kdn00"
    The term 'get-aduserm1kdn00' is not recognized as the name of a cmdlet, function, script file, or operable program. Che
    ck the spelling of the name, or if a path was included, verify that the path is correct and try again.
    At line:1 char:27
    + $user= get-aduser"m1kdn00" <<<<
    + CategoryInfo : ObjectNotFound: (get-aduserm1kdn00:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

    You need a space after the command get-aduser and the parameter "m1kdn00"
    \\uSlackr
    kdn242User is Offline
    New Member
    New Member
    Posts:6
    Avatar

    --
    10 Jun 2011 06:35 AM
    PS C:\Users\m1kdn00\Documents> $cool= get-aduser "m1kdn00"
    The term 'get-aduser' is not recognized as the name of a cmdlet, function, script file, or operable
    spelling of the name, or if a path was included, verify that the path is correct and try again.
    At line:1 char:18
    + $cool= get-aduser <<<< "m1kdn00"
    + CategoryInfo : ObjectNotFound: (get-aduser:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

    I can't install the Get-ADUser snapin because of restriction of my company policy. Do you have anyway around this ?

    Thanks,
    uSlackrUser is Offline
    New Member
    New Member
    Posts:68
    Avatar

    --
    10 Jun 2011 12:03 PM
    I recommend you speak with your manager about that. Sorry.
    \\uSlackr
    kdn242User is Offline
    New Member
    New Member
    Posts:6
    Avatar

    --
    13 Jun 2011 07:49 AM
    this is how i make it work

    $struser= "enter your user ID" (input the user ID you want to look for )
    $dom=[System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()
    $root= $dom.GetDirectoryEntry()
    $search = [System.DirectoryServices.DirectorySearcher]$root
    $search.Filter = "(cn=$struser)"
    $result = $search.FindOne()
    if ($result -ne $null) {$result.properties.distinguishedname} else {Write-Host $struser "does not exit"}


    I want to make it print out in kind of a form. Do you know any way I can do it ?
    You are not authorized to post a reply.


    Active Forums 4.3
    right
    footer   footer
    footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2 footer
    footer   footer