Error: "Get-ADUser : The operation returned because the timeout limit was exceeded."

Error: "Get-ADUser : The operation returned because the timeout limit was exceeded."

我正在创建一个脚本来将特定信息从现有 AD 用户复制到新帐户中。该脚本给了我 3 个错误,我知道的第三个错误是因为脚本在到达该部分之前失败了。

Get-ADUser :由于超过超时限制而返回的操作。
在 line:115 char:14
+ $New_Path = (Get-ADUser ($UsernameCopy.Text)).DistinguishedName -repl ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo:OperationTimeout:(cnelsontest:ADUser)[Get-ADUser],TimeoutException
    + FullyQualifiedErrorId : ActiveDirectoryCmdlet:System.TimeoutException,Microsoft.ActiveDirectory.Management.Commands.GetADUser

New-ADUser:无法验证参数 'Path' 的参数。参数为 null 或空。提供一个不为 null 或空的参数,然后尝试命令
再次。
在 line:155 char:35
+ New-ADUser -Name $New_DisplayName @params
+ ~~~~~~~
    + CategoryInfo : InvalidData: (:) [New-ADUser], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.ActiveDirectory.Management.Commands.NewADUser

Add-ADGroupMember:找不到标识为 'cnelsontest1' 的对象:'DC=azcorrections,DC=local'。
在 line:159 char:29
+ 添加 ADGroupMember - 成员 $Username.Text
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo:ObjectNotFound:(cnelsontest1:ADPrincipal)[Add-ADGroupMember],ADIdentityNotFoundException
    + FullyQualifiedErrorId : SetADGroupMember.ValidateMembersParameter,Microsoft.ActiveDirectory.Management.Commands.AddADGroupMember

Full Script link

这是第一个错误所指的行:

$New_Path = (Get-ADUser ($UsernameCopy.Text)).DistinguishedName -replace '^.*?,\s*(?=ou=)', ''

我感觉第二个错误信息是第一个错误引起的,第三个错误信息是因为它没有完成New-ADUser命令。

我是 运行 PSVersion 5.1.150

编辑:有人可以帮我弄清楚错误消息的含义以及解决方法吗?

您 运行 被抛出三个不同的错误:

  1. Get-ADUser : The operation returned because the timeout limit was exceeded.

这个很明显。您在 AD 服务器上有一个超时,并且在它找到结果之前就已经超时了。可以调整超时或者处理no returns.

  1. New-ADUser : Cannot validate argument on parameter 'Path'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.

您提供了错误的(空的)路径参数。

  1. Add-ADGroupMember : Cannot find an object with identity: 'cnelsontest1' under: 'DC=azcorrections,DC=local'.

对象 cnelsontest1DC=azcorrections,DC=local 路径中不存在。