Import ad account, need two account, PS file and CSV file
PS File:
Import-csv-encoding Unicode user.csv |foreach-object{
$Nam =$_.name
$GIVN =$_.givenname
$Surn =$_.surname
$PASSW =$_.password
$Des =$_.description
$City =$_.city
$Emplyenum =$_.employeenumber
$Mobile =$_.mobilephone
$com = "@test. com"
$secure =convertto-securestring-string $PASSW-asplaintext-force
New-aduser-name $Nam-samaccountname $Nam-givenname $Givn-surname $Surn-description $Des-displayname ($Surn + $Givn)-E MailAddress ($Nam + $com)-enabled $true-passwordneverexpires $true-path "ou=hr,dc=test,dc=com"-cannotchangepassword $ False-changepasswordatlogon $false-accountpassword $secure-userprincipalname ($Nam + $com)-homepage "www.test.com"- EmployeeNumber $Emplyenum-mobilephone $Mobile-city $City
}
CSV file
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/7A/02/wKioL1agpGyB1RN1AABN9jnWNQ8201.png "title=" Csv.png "alt=" Wkiol1agpgyb1rn1aabn9jnwnq8201.png "/>
Put in the consent directory, run the PS script to add users.
The following two commands can be enabled for the added AD user, mailbox
Ps>add-pssnapin Microsoft.Exchange.Management.PowerShell.SnapIn
Ps>get-user-resultsize unlimited-recipienttypedetails user| where {$_.userprincipalname-ne $null} | Enable-mailbox-database Mail1
This article is from the "green Light Dad" blog, please make sure to keep this source http://lvguangbaba.blog.51cto.com/1271362/1737319
PowerShell import AD Users and mailbox-enabled