|
Re: Create new user account This is really frustrating.
On Exchange 2007 you can do this
$username = Read-Host "Enter Username: "
$password = Read-Host "Enter password: " -AsSecureString
New-MailUser -Name $username -Password $password -ExternalEmailAddress
($username + "@test.com").ToString() -UserPrincipalName ($username +
"@test.com").ToString() -Organizational test.com/test
It will create a user account, and its way it should be done in
PowerShell. Clean, simple, documented.
To PowerShell team.
You have created something very very good.
I have created script that converts event logs from servers into RSS
feed in less then 3 hours.
And I'm struggling to create simple user in AD, please add some of
Exchange 2007 stuff into final release. Please.
Krunoslav
Jim Holbach wrote:
> All I've been able to come up with so far is this. I haven't been able to set
> the password yet.
>
> $ou=[ADSI]"LDAP://cn=Users,dc=test,dc=com"
> $user = $ou.Create("user","cn=User1")
> $user.Put("sAMAccountName", "User1")
> $user.SetInfo()
>
> $User.put("useraccountcontrol",$User.useraccountcontrol.value -band (-bnot 2))
> $user.SetInfo()
>
> $Group=[ADSI]"LDAP://cn=dnsadmins,cn=Users,dc=test,dc=com"
> $Group.PutEx(3, "member", @("cn=User1,cn=Users,dc=test,dc=com"))
> $Group.SetInfo()
>
> ---
> Jim Holbach
>
>
> "krukinews@gmail.com" wrote:
>
> > Hi,
> >
> > I'm trying to create new user in AD.
> >
> > $ou=[ADSI]"LDAP://ou=myUsers,dc=test,dc=com"
> > $user = $ou.Create("user","cn="User1")
> > $user.Put("sAMAccountName", "User1")
> > $user.SetInfo()
> >
> > But this only creates disabled user (without password).
> >
> > How can I set password and enable this user?
> > Also how can I add user to some group?
> >
> > Krunoslav
> >
> > |