建立文本文档另存为csv文件,注意编码格式,否则导入后是乱码
我们拥有十载网页设计和网站建设经验,从网站策划到网站制作,我们的网页设计师为您提供的解决方案。为企业提供成都做网站、成都网站设计、微信开发、小程序制作、手机网站制作、H5场景定制、等业务。无论您有什么样的网站设计或者设计方案要求,我们都将富于创造性的提供专业设计服务并满足您的需求。使用powellshell命令导入
Import-Csv -Path E:\users.csv | foreach { new-aduser -name $_.name -SamAccountName $_.samaccountname -GivenName $_.givenname -Surname $_.surname -DisplayName $_.displayname -Path $_.path -UserPrincipalName $_.userprincipalname -AccountPassword (ConvertTo-SecureString -string $_.accountpassword -AsPlainText -Force ) -Enabled $true -ChangePasswordAtLogon $false }
3.查看建立的用户
其他:
导出用户的命令
第一步,先获取AD上所有的OU 命令:Get-ADOrganizationalUnit -Filter 'Name -like "*"'
第二部,根据OU获取用户 命令:
Get-ADuser -searchbase 'OU=IT,DC=dareway,DC=com' -filter 'name -Like "*" ' -Properties * | Export-Csv c:\sharepointinfo.csv -enconding utf8
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
name,SamAccountName,GivenName,Surname,DisplayName,Department,UserPrincipalName,City,Office,StreetAddress,State,PostalCode,Title,Company,OfficePhone,HomePhone,MobilePhone,emailaddress
-------------------------------------------------------------------------------------------------------------------------------------------------------
获取用户信息中所需要的字段:
Get-ADuser -searchbase 'OU=IT,DC=dareway,DC=com' -filter 'name -Like "*" ' -Properties name,SamAccountName,GivenName,Surname,DisplayName,Department,UserPrincipalName,City,Office,StreetAddress,State,PostalCode,Title,Company,OfficePhone,HomePhone,MobilePhone,emailaddress | Export-Csv c:\sharepointinfo.csv -enconding utf8
导入用户的命令
将CSV文件用记事本打开,并另存为Unicode编码
PS C:\Users\Administrator\Desktop> Import-Csv "e:\file.csv" | foreach-object {New-ADUser -Path "ou=IT,dc=dareway,dc=cn"
-Name $_.name -SamAccountName $_.SamAccountName -GivenName $_.GivenName -Surname $_.Surname -DisplayName $_.DisplayName
-Department $_.Department -UserPrincipalName $_.UserPrincipalName -City $_.City -Office $_.Office -StreetAddress $_.Stre
etAddress -State $_.State -PostalCode $_.PostalCode -Title $_.Title -Company $_.Company -OfficePhone $_.OfficePhone -Hom
ePhone $_.HomePhone -MobilePhone $_.MobilePhone -emailaddress $_.emailaddress -AccountPassword (ConvertTo-SecureString "
Dareway@2018" -AsPlainText -force) -enabled $true -ChangePasswordAtLogon $true -PasswordNeverExpires $false -Passthru}
----------------------------------------------------------------------------------------------------------------------------------------------------
随机生成初始密码
Import-Csv "e:\file.csv" | foreach-object {New-ADUser -Path "ou=IT,dc=dareway,dc=cn" -Name $_.name -SamAccountName $_.SamAccountName -GivenName $_.GivenName -Surname $_.Surname -DisplayName $_.DisplayName
-Department $_.Department -UserPrincipalName $_.UserPrincipalName -City $_.City -Office $_.Office -StreetAddress $_.Stre
etAddress -State $_.State -PostalCode $_.PostalCode -Title $_.Title -Company $_.Company -OfficePhone $_.OfficePhone -Hom
ePhone $_.HomePhone -MobilePhone $_.MobilePhone -emailaddress $_.emailaddress -AccountPassword (ConvertTo-SecureString $_.password -AsPlainText -force) -enabled $true -ChangePasswordAtLogon $False -PasswordNeverExpires $false -Passthru}
----------------------------------------------------------------------------------------------------------------------------------------------------
获取OU Beijing(包含子OU)下所有的user类型账户
get-user –OrganizationalUnit IT | where-object{$_.RecipientType –eq “User”}
批量启用用户
get-user –OrganizationalUnit IT | where-object{$_.RecipientType –eq “User”} | Enable-Mailbox –Database “Mailbox Database 0839106375” | get-mailbox | select name,windowsemailaddress,database
另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。