powershell - 通过 powershell true CSV 导入用户
问题描述
嘿,我在 csv 文件的帮助下尝试通过 powersheel 创建新用户时遇到了麻烦,我没有从这个错误中得到任何更明智的结果。
New-ADOrganizationalUnit -Name "Vroege" -ProtectedFromAccidentalDeletion $False
New-ADOrganizationalUnit -Name "Late" -ProtectedFromAccidentalDeletion $False
#importing modules
Import-Module ActiveDirectory
$filepad = Read-Host -Prompt "vul hier het pad in waar de file zig bevind"
$users = Import-Csv $filepad
#LOOP
foreach ($user in $users) {
#info verzammelen
$Fname = $user.'First Name'
$Lname = $user.'Last Name'
$Officephone = $user.'Office Phone'
$jtitle = $user.'Job Title'
$OUpath = $user.'Orgianizational Unit'
$Password = $user.Password
#creating users
New-ADUser -Name "$Fname $Lname" -GivenName $Fname -Surname $Lname -UserPrincipalName "$Fname.$Lname@mvdb.test" -Path $OUpath -AccountPassword ( ConvertTo-SecureString $Password -AsPlainText -Force ) -ChangePasswordAtLogon $False -OfficePhone $Officephone -Enabled $True
#echo output
echo "de account zijn aangemaakt voor $fname $Lname in $OUpath"
}
这是我得到的想法是从CSV文件导入用户的错误,直接在
New-ADUser : No superior reference has been configured for the directory service. The directory service is therefore unable
to issue referrals to objects outside this forest
At C:\Users\mikevdb_admin\Desktop\Untitled1.ps1:22 char:5
+ New-ADUser -Name "$Fname $Lname" -GivenName $Fname -Surname $Lnam ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (CN=Wes Sieders,OU=Late:String) [New-ADUser], ADException
+ FullyQualifiedErrorId : ActiveDirectoryServer:8406,Microsoft.ActiveDirectory.Management.Commands.NewADUser
解决方案
推荐阅读
- assembly - 这个 MIPS 汇编程序中的 lw 和 la 有什么区别?
- mongoose - Mongoose - find() - 基于变量
- javascript - Fetch API 的 json 打印未定义?
- ios - 约束不适用于 UITableViewController 的 Cell 内的 UITextField
- dart - CupertinoTabBar 阻止当前选项卡底部如何避免这种情况还是默认行为
- firebase - Chrome 扩展的 GCM 到 FCM
- javascript - 使用元素
- function - 如何对多个输入求和?
- c++ - 从用户输入创建 C++ 文本金字塔
- python - 使用 Python OSRM 进行路由捕捉