我用伪造的用户数据创建了一个csv文件。此数据将用于填充测试Active Directory。在此之前,我必须先使用Powershell才能正确读取CSV的内容。
可以通过以下命令行重复此问题:
$ADUsers = Import-Csv "C:\temp\randomNames.csv" -Header firstname, lastname, username, department, password, orgunit:
foreach ($User in $ADUsers) {
$Username = $User.username
$Password = $User.password
$Firstname = $User.firstname
$Lastname = $User.lastname
$Department = $User.department
$OU = $User.orgunit
Write-Host $Username
Write-Host $Password
Write-Host $Firstname
Write-Host $Lastname
Write-Host $Department
Write-Host $OU
}
当脚本运行时,它会打印出所有精细的内容,但OU变量除外。我不知道我在这里想念什么。
以下是CSV文件的摘录:
firstname,lastname,username,department,password,orgunit Karry,Dwyer,KaDwyer,Marketing,happy1,"CN=Users,OU=bob,OU=com" Johanna,Moon,JoMoon,Facilities,hentai,"CN=Users,OU=bob,OU=com" Beatrice,Gropper,BeGropper,Messaging,12341234,"CN=Users,OU=bob,OU=com" Rachelle,Houng,RaHoung,Research,jackson,"CN=Users,OU=bob,OU=com" Leland,Smit,LeSmit,Executive,brother,"CN=Users,OU=bob,OU=com" Marlin,Pyro,MaPyro,Engineering,123654,"CN=Users,OU=bob,OU=com" Taisha,Goto,TaGoto,DBA,222222,"CN=Users,OU=bob,OU=com" Estelle,Holtzclaw,EsHoltzclaw,Engineering,ranger,"CN=Users,OU=bob,OU=com"