Chinaunix首页 | 论坛 | 博客
  • 博客访问: 408464
  • 博文数量: 87
  • 博客积分: 6015
  • 博客等级: 准将
  • 技术积分: 960
  • 用 户 组: 普通用户
  • 注册时间: 2006-09-13 16:59
文章分类
文章存档

2015年(4)

2010年(16)

2009年(13)

2008年(12)

2007年(29)

2006年(13)

我的朋友

分类: WINDOWS

2015-09-08 10:40:02

我在前面写过一篇使用For 语句和 dsquery 添加用户的例子,现在新版本的AD服务器出来后,我们现在可以使用Powershell 脚本来达成这个目标。我们要了解下Powershell的语法:

 
语法
    New-ADUser [-Name] <string> [-AccountExpirationDate <System.Nullable[System.DateTime]>] [-AccountNotDelegated <Syst
    em.Nullable[bool]>] [-AccountPassword <SecureString>] [-AllowReversiblePasswordEncryption <System.Nullable[bool]>]
    [-AuthType {Negotiate | Basic}] [-CannotChangePassword <System.Nullable[bool]>] [-Certificates <X509Certificate[]>]
     [-ChangePasswordAtLogon <System.Nullable[bool]>] [-City <string>] [-Company <string>] [-Country <string>] [-Creden
    tial <PSCredential>] [-Department <string>] [-Description <string>] [-DisplayName <string>] [-Division <string>] [-
    EmailAddress <string>] [-EmployeeID <string>] [-EmployeeNumber <string>] [-Enabled <System.Nullable[bool]>] [-Fax <
    string>] [-GivenName <string>] [-HomeDirectory <string>] [-HomeDrive <string>] [-HomePage <string>] [-HomePhone <st
    ring>] [-Initials <string>] [-Instance <ADUser>] [-LogonWorkstations <string>] [-Manager <ADUser>] [-MobilePhone <s
    tring>] [-Office <string>] [-OfficePhone <string>] [-Organization <string>] [-OtherAttributes <hashtable>] [-OtherN
    ame <string>] [-PassThru <switch>] [-PasswordNeverExpires <System.Nullable[bool]>] [-PasswordNotRequired <System.Nu
    llable[bool]>] [-Path <string>] [-POBox <string>] [-PostalCode <string>] [-ProfilePath <string>] [-SamAccountName <
    string>] [-ScriptPath <string>] [-Server <string>] [-ServicePrincipalNames <string[]>] [-SmartcardLogonRequired <Sy
    stem.Nullable[bool]>] [-State <string>] [-StreetAddress <string>] [-Surname <string>] [-Title <string>] [-TrustedFo
    rDelegation <System.Nullable[bool]>] [-Type <string>] [-UserPrincipalName <string>] [-Confirm] [-WhatIf] [<CommonPa
    rameters>]

 

我们先编辑好相应的CSV文件,有几个选项是必选的,下面截图列出必选的条目,这里我们稍微解释下,samaccountname 是必选项,代表他登录的名称,Givenname和surname 分别是姓和名,Displayname 是显示名称,Path 代表的对象存放的OU:


阅读(770) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~