且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Powershell管理系列(三十一)PowerShell操作之批量创建邮箱

更新时间:2022-10-10 17:22:56

用户需要批量导入邮箱,提供的信息,如姓名、别名、组织单元、显示名、登录名、密码、公司名、部门、邮箱配额,表格如下图

Powershell管理系列(三十一)PowerShell操作之批量创建邮箱

步骤1、在powershell中输入如下命令:

Add-PSSnapin microsoft.exchange*
Import-Module activedirectory
Import-Csv C:\mbxinfo.csv | ForEach-Object `
{
new-mailbox -Name $_.name -Alias $_.alias -OrganizationalUnit $_.ou -DisplayName $_.displayname -UserPrincipalName $_.upn `
-Password (ConvertTo-SecureString -String $_.pwd -AsPlainText -Force)
set-mailbox -Identity $_.upn -IssueWarningQuota $_.IssueWarningQuota -ProhibitSendQuota $_.ProhibitSendQuota `
-ProhibitSendReceiveQuota $_.ProhibitSendReceiveQuota -UseDatabaseQuotaDefaults $false 
Set-User -Identity $_.upn -Company $_.company -Department $_.dept
}
Powershell管理系列(三十一)PowerShell操作之批量创建邮箱

步骤2、我们检查,可以看到邮箱和ad账号都已经批量建好

Powershell管理系列(三十一)PowerShell操作之批量创建邮箱

Powershell管理系列(三十一)PowerShell操作之批量创建邮箱


本文转自 zhou_ping 51CTO博客,原文链接:http://blog.51cto.com/yuntcloud/1772885,如需转载请自行联系原作者