write-output "本命令用来快速创建非用户的域帐户和邮箱,默认保存在tech.xxx.com/非用户账户/mailbox下,密码Super@123"
$a = Read-Host("请输入非用户邮箱的英文部分,这个部分也是用户的登陆名,例如:SuperTestUser")
$b = Read-Host("请输入非用户邮箱的中文部分,也就是显示名称,例如:测试用户")
$pass = ConvertTo-SecureString -AsPlainText Super@123 -Force
New-Mailbox -Name $b -Alias $a -OrganizationalUnit 'tech.xxx.com/test/mailbox' -UserPrincipalName $a@bbb.contoso.com -SamAccountName $a -FirstName '' -Initials '' -LastName '' -password $pass -ResetPasswordOnNextLogon $false
以上为交互式输入,操作起来赏心悦目,更关键的是速度快。自动创建域账户,给定密码Super@123。
非交互式如下:
$a = "SuperTestUser"
$b = "测试用户"
$pass = ConvertTo-SecureString -AsPlainText Super@123 -Force
New-Mailbox -Name $b -Alias $a -OrganizationalUnit 'tech.xxx.com/test/mailbox' -UserPrincipalName $a@bbb.contoso.com -SamAccountName $a -FirstName '' -Initials '' -LastName '' -password $pass -ResetPasswordOnNextLogon $false
PS:
- powershell 下执行 exchange 命令需要先加载 exchange 模块
- 参数 -OrganizationalUnit 可以缺省
- 参数 -UserPrincipalName 后面的
@bbb.contoso.com
需要按照自己域环境相应修改