首页 > 解决方案 > 通过 powershell tr​​ue 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

标签: powershellpowershell-4.0windows-server-2016

解决方案



推荐阅读