是一种快速且高效的方法,可以通过一次性导入CSV文件来批量创建多个用户账号。CSV(Comma-Separated Values)是一种常见的文件格式,用逗号或其他分隔符将数据字段分隔开。
在AD(Active Directory)中创建批量用户的步骤如下:
Import-Module ActiveDirectory
$csvFile = "C:\path\to\users.csv"
$users = Import-Csv $csvFile
foreach ($user in $users) {
$username = $user.Username
$password = $user.Password
$name = $user.Name
$email = $user.Email
$securePassword = ConvertTo-SecureString -String $password -AsPlainText -Force
$userParams = @{
SamAccountName = $username
UserPrincipalName = "$username@domain.com"
Name = $name
GivenName = $name.Split()[0]
Surname = $name.Split()[1]
EmailAddress = $email
Enabled = $true
PasswordNeverExpires = $true
Password = $securePassword
}
New-ADUser @userParams
}
New-ADUser
命令在AD中创建用户账号。使用CSV在AD中创建批量用户的优势是:
适用场景:
腾讯云相关产品和产品介绍链接地址:
领取专属 10元无门槛券
手把手带您无忧上云