Create AD User Remotely

This topic contains 0 replies, has 1 voice, and was last updated by  Forums Archives 5 years, 10 months ago.

  • Author
    Posts
  • #6311

    by HighFiv3 at 2013-03-27 06:58:07

    Hi Guy's ,

    i want to Create AD User Remotely in my Domain.
    The script will be running on my Desktopcomputer not on the Server.

    At the moment i have one Problem. I have no idea to move the AD User into a Group. How i can do this without Import the AD Module?
    This my code:
    $usersOU = [ADSI] "LDAP://cn=users,dc=domain,dc=TLD"
    $newUser = $usersOU.Create("user","cn=$Name")
    #$newUser = $usersOU.Create("user","cn=$kuerzel")
    $newUser.put("givenname", "$Vorname")
    $newUser.put("sn", "$Nachname")
    $newUser.Put("displayName","$Vorname" + " " + "$Nachname")
    $newUser.Put("sAMAccountName", $kuerzel)
    $newUser.Put("userPrincipalName", "$upn")
    $newUser.Put("ScriptPath","logon_ip.cmd")
    $newUser.SetInfo()

    $newUser.psbase.InvokeSet("AccountDisabled", $false)
    $newUser.psbase.invoke("SetPassword","12345678")
    $newUser.CommitChanges()

    by coderaven at 2013-03-27 07:42:33

    Using ADSI, to add a user to a group you need to connect to the group and call the add function there. See one of Don's articles here

    You may want to look into remoting or the PowerShell Web Access to get around using ADSI.

    by HighFiv3 at 2013-03-27 08:21:37

    I have not fount a Memberof variable with my ADSI-Editor.. my DC is a 2008R2 is this maybe the problem?

    Greetz

    by coderaven at 2013-03-28 07:07:23

    The memberof is not a variable of the ADSI user. You will see the Properties though.

    $User.Properties["memberof"]

    This article from Richard Siddaway explains it better.

You must be logged in to reply to this topic.