Import-Module ActiveDirectory域= ' @TEST美元。当地的$ Userslist = import-csv“C: \ \用户公共\ Users.csv”域美元= ' isot.com ' Userslist美元= import-csv“C: \ \用户公共\ Users.csv”ForEach(用户Userslist美元){$ User。FirstName $ User。LastName $ User。用户ID FullName =美元。FirstName + " " + $ User。LastName UPN =美元用户。ID +域UNC美元= ' \ \ SERVER \ DATASHARE \ ' HomeDirectory = UNC美元+ $ User。ID New-ADUser -name $FullName -GivenName $User。FirstName姓$ User。LastName samaccountname $ User。ID -DisplayName $FullName -UserPrincipalName $UPN -AccountPassword (ConvertTo-SecureString -AsPlainText "p@ssw0rd" -force) -Path 'OU=Domain Users,DC=TEST,DC=local' -HomeDirectory $HomeDirectory -HomeDrive 'U:' Set-ADUser -Identity $User。ID -PasswordNeverExpires $True启用adaccount -Identity $User。Id Add-ADGroupMember -Identity Faculty -Members $User。ID}