Active Directory Users


hi all, im relatively new powershell scripting , im hoping learn alot here!! :)

 

okay so, have base script adding user in ad, cannot work out why fails life of me

$class = "user"
$strusername = "cn=john doe"

$objadsi = [adsi]"ldap://ou=[ou],dc=[domain],dc=[domain],dc=[domain]
$objuser = $objadsi.create($class,$strusername)
$objuser.put("samaccountname", "jdoe")
$objuser.setinfo()

when use it fails, learnt of tutorial found on internet.

 

any , appreciated.

 


the error message doesn't make sense me. unless there non-display character in string "jdoe".

oh wait, see. adspath in first statement lacks trailing quote character. try:

$objadsi = [adsi]"ldap://ou=[ou],dc=[domain],dc=[domain],dc=[domain]"

added final quote. problem?

 


richard mueller - mvp directory services


Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Error: 0x80073701 when trying to add Print Services Role in Windows 2012 Standard

Disconnecting from a Windows Server 2012 R2 file sharing session on a Windows 7,8,10 machine

Event ID 64,77,1008 Certificates Events Windows Server 2008, 2008R2