I. Bulk mailbox creation via PowerShell
Set-Location C:\Users\fanyx_v\Desktop\
Import-module ActiveDirectory
Add-pssnapin microsoft.exchange*
Add-pssnapin Microsoft.Exchange.Management.PowerShell.SnapIn
$ADUser =import-csv-path. \newuser.csv-useculture-encoding Default
foreach ($Users in $ADUser)
{
$UserPrincipalName = $Users. userPrincipalName #每个用户帐户都有用户主体名称 (UPN), formatted as:<user>@<dns-domain-name>. #
# $Company = $Users. Company #指定用户所在的公司. #
$Department = $Users. Department #指定用户所在的部门. #
$DisplayName = $Users. DisplayName #指定对象的显示名称. #
$Name = $Users. Name #指定对象的名称. #
$SamAccountName = $Users. sAMAccountName
$Description = $Users. Description #账户的描述信息 #
$Manager = $Users. Manager #指定用户的经理. #
# $AccountPassword = $Users. Accountpassword # Specify a new password value for the account. #
$MobilePhone = $Users. Mobilephone #指定用户的移动电话号码.
$AccountExpirationDate = $Users. accountExpirationDate #指定用户的过期时间
#根据需要添加New-ADUser -Name $Name -Manager $Manager -AccountExpirationDate $AccountExpirationDate -UserPrincipalName $UserPrincipalName -Department $Department -SamAccountName $SamAccountName -DisplayName $DisplayName -Description $Description -ChangePasswordAtLogon 0 -AccountPassword (ConvertTo-SecureString "2q3eNChZ" -AsPlainText -Force) -Enabled 1 -Path "OU=测试公司,DC=demo,DC=com"sleep 20 #延迟数Enable-Mailbox $users.SamAccountName -Database "database"
}
Second, export some information for everyone under the specified OU
Get-aduser-filter -searchbase "ou= test company, dc=demo,dc=com"-properties | Select Name,whencreated,passwordlastset,samaccountname | Export-csv creat_time.csv-notypeinformation-encoding UTF8
Third, bulk create contacts
Import-csv C:\Users\fanyxV\desktop\contact.csv | ForEach {New-mailcontact-alias $. Alias-name $. displayname-externalemailaddress $. targetaddress}
PowerShell share small statements commonly used in 5--ad