你如何添加从CSV文件中的用户使用PowerShell的活动目录(AD)和Exchange? [英] How do you add users from a CSV file to Active Directory (AD) and Exchange using PowerShell?

查看:497
本文介绍了你如何添加从CSV文件中的用户使用PowerShell的活动目录(AD)和Exchange?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将如何使用PowerShell的一个CSV文件中添加一组用户到Active Directory?

How would one add a group of users to Active Directory from a csv file using PowerShell?

CSV文件将包含的第一个,最后一个,电子邮件,临时密码,并描述了用户使用。该OU,权限等可能很难codeD。

The csv file would contain the first, last, email, temp password, and description for the users. The OU, permissions, and etc. could be hard coded.

这个脚本应该还添加Exchange 2007邮箱。

The script should also add an Exchange 2007 email box.

推荐答案

CSV文件应包含一个标题行的所有字段名。

The csv file should contain a header row with all the field names.

下面是code:

$Users = Import-Csv ".\UsersFile.csv"
foreach ($User in $Users)
{
    New-Mailbox -Name $User.Name -Alias $User.MailboxAlias `
        -OrganizationalUnit $User.OU `
        -UserPrincipalName $User.UPN -SamAccountName $User.UserName `
        -FirstName $User.First -Initials $USer.Initial -LastName $User.Last `
        -Password $User.Password -ResetPasswordOnNextLogon $false `
        -Database 'MailboxDatabaseFilename'
}

这篇关于你如何添加从CSV文件中的用户使用PowerShell的活动目录(AD)和Exchange?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆