How To Create AD Users with PowerShell

SYNTAX:
CreateUser.Ps1 -name "CN=johnny" -ou "ou=TestOU" -dc "dc=ehloex,dc=lab"

   1: if($ou)
   2:  {  "Creating user $name in LDAP://$ou,$dc"  
   3:   $ADSI = [ADSI]"LDAP://$ou,$dc" 
   4:  }
   5: ELSE
   6:  { "Creating user $name in LDAP://cn=users,$dc" 
   7:   $ADSI = [ADSI]"LDAP://cn=users,$dc" 
   8:  } 
   9:  
  10: $CLass = "User"
  11: $User = $ADSI.create($CLass, $Name)
  12: $User.setInfo()

Enjoy it.

posted on 2008-05-21 00:51  johnny tu  阅读(416)  评论(0编辑  收藏  举报

导航