0
votes

I am working on creating a script to copy specific information from an existing AD User into a new account. The script is giving me 3 errors, the third one i know is because the script fails before it gets to that section.

Get-ADUser : The operation returned because the timeout limit was exceeded.
At 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 : 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.
At line:155 char:35
+ New-ADUser -Name $New_DisplayName @params
+                                   ~~~~~~~
    + CategoryInfo          : InvalidData: (:) [New-ADUser], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.ActiveDirectory.Management.Commands.NewADUser

Add-ADGroupMember : Cannot find an object with identity: 'cnelsontest1' under: 'DC=azcorrections,DC=local'.
At line:159 char:29
+                             Add-ADGroupMember -Members $Username.Text
+                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (cnelsontest1:ADPrincipal) [Add-ADGroupMember], ADIdentityNotFoundException
    + FullyQualifiedErrorId : SetADGroupMember.ValidateMembersParameter,Microsoft.ActiveDirectory.Management.Commands.AddADGroupMember

Full Script link

Here is the line the first error refers to:

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

I have a feeling the second error message is caused by the first error, and the third error message is because it doesn't complete the New-ADUser command.

I'm running PSVersion 5.1.150

Edit: Can someone assist me in figuring out what the error messages mean as well as how to fix it?

1
Flagged as "Unclear what you're asking" - Jeff Zeitlin
Don't forget to ask your question. - Bill_Stewart
Edited to ask a question - cnelson
The error means exactly what it says. The request to the DC is taking too long to actually return data so it gives up. - EBGreen

1 Answers

0
votes

You're running into three different errors being thrown:

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

This one is obvious. You have a timeout on the AD server and it was exceeded before it found a result. You can adjust the timeout or deal with 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.

You provided a bad (empty) path argument.

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

The object cnelsontest1 doesn't exist in the DC=azcorrections,DC=local path.