批量创建AD用户
2014-05-21 16:22
323 查看
批量创建AD用户 前几天我发表了《Powershell 管理Active Directory常用命令》这个博客,里面有关于创建用户的Powershell,但是如果是单用户的话,用Powershell就显得不是那么的高效了,所以我们现在来做一下批量的形式
环境:
操作系统:Windows Server 2012
域控制器:xiaohui.srv.com
首先呢,我们来把用户都在Excel里写好,如下图,第一行是我们要用到的用户属性,如果你有需求还能自己加,比如ou这样的
650) this.width=650;" style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image002" border="0" alt="clip_image002" src="http://img1.51cto.com/attachment/201208/9/4042188_1344474987I9hq.jpg" "544" height="312" />
我们把Excel另存为CSV格式
650) this.width=650;" style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image004" border="0" alt="clip_image004" src="http://img1.51cto.com/attachment/201208/9/4042188_1344474987G1hN.jpg" "353" height="342" />
然后我们打开Powershell,执行以下命令
$password = convertto-securestring -String "abc123,.!" -AsPlainText –Force
Import-Csv "C:\Users\Administrator\Desktop\ Cteate Users1.csv " | %{New-ADUser -Name $_.name -SamAccountName $_.SamAccountName -userprincipalname $_.userprincipalname -givenname $_.givenname -surname $_.surname -displayname $_.name -accountpassword $password -enabled $true -path $_.path"}
650) this.width=650;" style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image006" border="0" alt="clip_image006" src="http://img1.51cto.com/attachment/201208/9/4042188_1344474987ddkB.jpg" "544" height="75" />
这一行,是定义password是一个加密的字符串,内容是abc123,.!,这个就是我们用户的密码
好了,我们通过下图,已经看到了命令已经执行成功
650) this.width=650;" style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image008" border="0" alt="clip_image008" src="http://img1.51cto.com/attachment/201208/9/4042188_1344474988soYj.jpg" "544" height="94" />
650) this.width=650;" style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image010" border="0" alt="clip_image010" src="http://img1.51cto.com/attachment/201208/9/4042188_1344474988Azct.jpg" "544" height="272" />
650) this.width=650;" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image012" border="0" alt="clip_image012" src="http://img1.51cto.com/attachment/201208/9/4042188_1344474988O9Np.jpg" "544" height="277" />
我们来解释一下,import-csv这是个简单了,就是来导入我们的csv文件
后面的new-aduser在我前面写过,是新建AD用户的,我们主要来讲一下$_.XXX怎么用的
-Name $_.name -SamAccountName $_.SamAccountName,以这个来讲,-name后面我们都知道加上用户名的,那我们加上$_.name的意思呢,就是去匹配我们excel里的第一行中的name属性,SamAccountName也是一样的,最后我们加上$_.path,新建的用户,直接就出现在了它该出现的位置上,万事大吉
本文出自 “阳光☆奋进” 博客,请务必保留此出处http://ucweb.blog.51cto.com/4042188/959037
环境:
操作系统:Windows Server 2012
域控制器:xiaohui.srv.com
首先呢,我们来把用户都在Excel里写好,如下图,第一行是我们要用到的用户属性,如果你有需求还能自己加,比如ou这样的
650) this.width=650;" style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image002" border="0" alt="clip_image002" src="http://img1.51cto.com/attachment/201208/9/4042188_1344474987I9hq.jpg" "544" height="312" />
我们把Excel另存为CSV格式
650) this.width=650;" style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image004" border="0" alt="clip_image004" src="http://img1.51cto.com/attachment/201208/9/4042188_1344474987G1hN.jpg" "353" height="342" />
然后我们打开Powershell,执行以下命令
$password = convertto-securestring -String "abc123,.!" -AsPlainText –Force
Import-Csv "C:\Users\Administrator\Desktop\ Cteate Users1.csv " | %{New-ADUser -Name $_.name -SamAccountName $_.SamAccountName -userprincipalname $_.userprincipalname -givenname $_.givenname -surname $_.surname -displayname $_.name -accountpassword $password -enabled $true -path $_.path"}
650) this.width=650;" style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image006" border="0" alt="clip_image006" src="http://img1.51cto.com/attachment/201208/9/4042188_1344474987ddkB.jpg" "544" height="75" />
这一行,是定义password是一个加密的字符串,内容是abc123,.!,这个就是我们用户的密码
好了,我们通过下图,已经看到了命令已经执行成功
650) this.width=650;" style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image008" border="0" alt="clip_image008" src="http://img1.51cto.com/attachment/201208/9/4042188_1344474988soYj.jpg" "544" height="94" />
650) this.width=650;" style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image010" border="0" alt="clip_image010" src="http://img1.51cto.com/attachment/201208/9/4042188_1344474988Azct.jpg" "544" height="272" />
650) this.width=650;" style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image012" border="0" alt="clip_image012" src="http://img1.51cto.com/attachment/201208/9/4042188_1344474988O9Np.jpg" "544" height="277" />
我们来解释一下,import-csv这是个简单了,就是来导入我们的csv文件
后面的new-aduser在我前面写过,是新建AD用户的,我们主要来讲一下$_.XXX怎么用的
-Name $_.name -SamAccountName $_.SamAccountName,以这个来讲,-name后面我们都知道加上用户名的,那我们加上$_.name的意思呢,就是去匹配我们excel里的第一行中的name属性,SamAccountName也是一样的,最后我们加上$_.path,新建的用户,直接就出现在了它该出现的位置上,万事大吉
本文出自 “阳光☆奋进” 博客,请务必保留此出处http://ucweb.blog.51cto.com/4042188/959037
相关文章推荐
- 使用DSADD来批量创建AD的用户
- Exchange 2010系列部署报告-批量创建AD用户、组和启用用户邮箱等
- 如何在AD中批量创建域用户
- 批量创建AD域用户
- 批量创建AD域用户
- PowerShell 批量创建AD用户账号
- AD(活动目录)批量创建用户!
- Windows Server 2003 AD中批量创建用户
- Windows Server 2003 AD中批量创建用户
- AD批量创建用户
- 批量创建AD用户 推荐
- 如何在AD中批量创建域用户
- Windows Server 2003 AD中批量创建用户
- For语句实现批量创建AD用户
- Oracle批量创建用户和导入导出的脚本
- AD:使用C#批量创建帐号
- 详细介绍Linux批量用户的创建
- 【AD用户设置系列二】批量修改漫游配置文件路径 推荐
- ldap中创建和AD中相同的用户显示名
- 企业信息化系统基础——AD:使用C#批量创建帐号