zoukankan      html  css  js  c++  java
  • 添加中文AD帐号

    功能:添加AD用户,帐号显示名为中文,登录名为英文。如显示名为乔丹,登录名为qiaodan。(举一反三,可以设置其他选项。)
    使用:见源码中注释。
    源码:
    cls
    #把用户名放在c:\name.txt文件里,一行一个账户
    #每个账户的格式为“姓,名,登录名”,比如:“乔,丹,Jordan”
    #注意:“,”为中文输入法下的逗号
    $account = Get-Content c:\name.txt
    $account | foreach {
                    $name = $_.split(",")
                    $firstname = $name[0]
                    $lastname = $name[1]
                    $loginname = $name[2]
                    $root = [ADSI]""
                    $rootdn = $root.distinguishedName
                    #修改路径到具体OU或CN的位置
                    $location = [ADSI]("LDAP://CN=Users," + $rootdn)

                    #创建新用户
                    $displayname = $firstname + $lastname
                    $newuser = $location.Create("User", "CN=" + $displayname)

                    #账户的登录名
                    $newuser.Put("sAMAccountName", $loginname)
                    $newuser.SetInfo()
                    #在@后自定义域名
                    $newuser.Put("UserPrincipalName", $loginname + "@mytest.com")
                    $newuser.SetInfo()

                    #账户姓,名
                    $newuser.Put("givenname", $firstname)
                    $newuser.SetInfo()
                    $newuser.Put("sn", $lastname)
                    $newuser.SetInfo()

                    #默认账户是开启的,若想默认关闭,修改$false为$true
                    $newuser.psbase.InvokeSet('AccountDisabled', $false)

                    #默认密码是P@ss123
                    $newUser.SetPassword("P@ss123")
                    }
  • 相关阅读:
    文档根元素 "beans" 必须匹配 DOCTYPE 根 "null"
    web.xml配置参数context-param和init-param的区别
    web.xml中通过contextConfigLocation的读取spring的配置文件
    Web.xml配置详解之context-param
    xml 文件 和xsd 文件的关系
    事务并发控制
    Java泛型详解
    MongoDB集群
    MongoDB集群——分片
    MongoDB集群——副本集
  • 原文地址:https://www.cnblogs.com/studio313/p/1622057.html
Copyright © 2011-2022 走看看