在其他域中创建AD用户



我创建了一系列用于创建域用户的脚本。由于我们创建用户的每个域都需要不同的参数和条件,所以我为每个域都有一个脚本。但在一个领域的情况下,我有一个问题。对于该领域,手动程序如下:

1( 打开dsa.msc

2( 连接到"xyz"域(用户是从"abc"域中的服务器创建的(

3( 创建用户(操作10到15分钟,这就是我创建脚本的原因(

不幸的是,当我运行脚本时,我在执行New-ADUser cmdlet时收到错误消息,即"服务器不愿意处理请求"(这是确切的完整错误消息(。我想原因是需要执行上述过程中的步骤2。所以我需要在脚本中模拟它,但我不知道如何做到这一点。

这就是命令的定义:

$params = @{
'GivenName'             = $First_name_val.Text
'Surname'               = $Second_name_val.Text
'DisplayName'           = $Display_name
'AccountPassword'       = $password
'Path'                  = $Location_val.Text
'Name'                  = $User_name_val.Text
'CannotChangePassword'  = $Cannot_chg_pass.Checked
'PasswordNeverExpires'  = $Pass_not_expires.Checked
'ChangePasswordAtLogon' = $Must_chg_pass.Checked
'Enabled'               = !($Account_disabled_val.Checked)
'Description'           = $GECOS_val.Text
'Office'                = "NA"
'OfficePhone'           = "NA"
'Title'                 = $Job_Title_val.Text
'Department'            = $Department_val.Text
'Company'               = $Company_val.Text
'SamAccountName'        = $User_name_val.Text
'UserPrincipalName'     = $User_name_val.Text + "@woodplc.com"
'EmailAddress'          = $Email_Address_val.Text
'PassThru'              = $true
}
$New_user = New-ADUser @params

$User_name_val.Text的定义如下:

#region Real name of the user
[void]$AD_user_creation.SuspendLayout()
$Display_name_lbl                = New-Object system.Windows.Forms.Label
$Display_name_lbl.text           = "User`'s real name"
$Display_name_lbl.AutoSize       = $true
$Display_name_lbl.width          = 25
$Display_name_lbl.height         = 10
$Display_name_lbl.location       = New-Object System.Drawing.Point(10,10)
$First_name_val                  = New-Object system.Windows.Forms.TextBox
$First_name_val.Text             = "a."
$First_name_val.multiline        = $false
$First_name_val.width            = 120
$First_name_val.height           = 20
$First_name_val.location         = New-Object System.Drawing.Point(200,10)
$Second_name_val                 = New-Object system.Windows.Forms.TextBox
$Second_name_val.multiline       = $false
$Second_name_val.width           = 120
$Second_name_val.height          = 20
$Second_name_val.location        = New-Object System.Drawing.Point(330,10)
$Display_name_val                = New-Object system.Windows.Forms.Label
$Display_name_val.Text           = ""
$Display_name_val.width          = 250
$Display_name_val.height         = 20
$Display_name_val.location       = New-Object System.Drawing.Point(200,40)
$showFullName = { $Display_name_val.Text = ($First_name_val.Text + "." + $Second_name_val.Text) }
[void]$Second_name_val.Add_Leave( { & $showFullName } )
[void]$First_name_val.Add_Leave(  { & $showFullName } )
#endregion
#region User name of the user
$User_name_lbl                   = New-Object system.Windows.Forms.Label
$User_name_lbl.text              = "User logon name"
$User_name_lbl.AutoSize          = $true
$User_name_lbl.width             = 25
$User_name_lbl.height            = 10
$User_name_lbl.location          = New-Object System.Drawing.Point(10,70)
$User_name_val                   = New-Object system.Windows.Forms.TextBox
$User_name_val.multiline         = $false
$User_name_val.width             = 250
$User_name_val.height            = 20
$User_name_val.location          = New-Object System.Drawing.Point(200,70)
$LogonName = {$User_name_val.Text = ($First_name_val.Text + "." + $Second_name_val.Text)}
[void]$Second_name_val.Add_Leave({& $LogonName})
[void]$First_name_val.Add_Leave({& $LogonName})
[void]$AD_user_creation.ResumeLayout()
#endregion

错误"The server is unwilling to process the request"表示某些输入值无效。例如,您提供的OU可能无效(可能是不应该存在的空格(,或者SamAccountName可能太长或包含无效字符,等等。

如果你显示你正在使用的完整命令,我可能会发现一些东西。

如果连接到服务器或进行身份验证时出现问题,则错误消息会有所不同。

相关内容

  • 没有找到相关文章

最新更新