New-ADComputer : A required attribute is missing - Issue using "-path"

I am trying to make a simple script to create a new computer object in AD.  I took out all variables and put the real data in and i get an error.  Below is the line of code I am trying to run.  Under that is the error.  Can somebody help me out?

CODE:

 New-ADComputer -Name XXXXXXXX -Description test -Path "OU=Laptop,OU=Computers,OU=SID,OU=US,OU=NA,OU=XXXXX,DC=XXX,DC=ad,DC=XXXXXX,DC=com" -SAMAccountName XXXXXXXX

ERROR:

New-ADComputer : A required attribute is missing
At line:1 char:1
+ New-ADComputer -Name XXXXXXXX -Description test -Path
"OU=Laptop,OU=Computers,OU ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~
    + CategoryInfo          : NotSpecified: (CN=XXXXXXXX,OU=...,DC=XXXX,DC=com
   :String) [New-ADComputer], ADException
    + FullyQualifiedErrorId : A required attribute is missing,Microsoft.Active
   Directory.Management.Commands.NewADComputer


August 15th, 2015 2:52pm

I suggest that you have an illegal character in one of your XXXX out names.

Free Windows Admin Tool Kit Click here and download it now
August 15th, 2015 3:14pm

Also, the sAMAccountName should be 20 characters or less, including the trailing "$" (the cmdlet adds it if you don't). The following are not allowed in sAMAccountNames:

" [ ] : ; | = + * ? < > / \ ,

The New-ADComputer cmdlet will escape any characters in the "Name" that might require it. Name is limited to 64 characters.

August 15th, 2015 8:14pm

New-ADComputer -Name L4NGH5R1 -Description test -Path "OU=Laptop,OU=Computers,OU=SID,OU=US,OU=NA,OU=XXXX Global,DC=abd,DC=ad,DC=XXXX,DC=com" -SAMAccountName L4NGH5R1$

that's the code I just rand and it still failed.

Free Windows Admin Tool Kit Click here and download it now
August 17th, 2015 10:01am

Your path is still likely bad. We can't tell though, since you keep editing it.

Copy it directly from ADUC instead of typing it and see if that helps you.

August 17th, 2015 10:09am

Are you running this on your DC? If not, have you got RSAT installed on your computer? Try specifying the -server switch to see if its an LDAP connection/permission issue.
Free Windows Admin Tool Kit Click here and download it now
August 17th, 2015 10:13am

Shouldn't all string values, like "Test" and "L4NGH5R1" be quoted?
August 17th, 2015 10:35am

I copied it directly from Object DN in the Object Tab in AD

Free Windows Admin Tool Kit Click here and download it now
August 17th, 2015 10:36am

New-ADComputer -Server "abd.ad.acco.com" -Name "L4NGH5R1" -Description "test" -Path "OU=Laptop,OU=Computers,OU=SID,OU=US,OU=NA,OU=ACCO Global,DC=abd,DC=ad,DC=acco,DC=com" -SAMAccountName "L4NGH5R1$"

there's the exact command.  It still failed with quotes and I have RSAT enabled.

August 17th, 2015 10:39am

You don't mention the error message, but is it possible the account you are using lacks permissions? If you are running the script at a PowerShell prompt, did you launch the prompt with "Run as administrator"?
Free Windows Admin Tool Kit Click here and download it now
August 17th, 2015 12:20pm

It is not necessary to elevate to use AD commands.  It is required that you have admin status to alter AD.

The error show that there is likely a network issue.

"A required attribute is missing,Microsoft.Active
   Directory.Management.Commands.NewADComputeR"

August 17th, 2015 12:46pm

I am running as administrator.  Get-ADComputer works fine.
Free Windows Admin Tool Kit Click here and download it now
August 17th, 2015 12:54pm

This is all you need to do:

New-ADComputer -Name L4NGH5R1 -Description test -Path 'OU=Laptop,OU=Computers,OU=SID,OU=US,OU=NA,OU=ACCO Global,DC=abd,DC=ad,DC=acco,DC=com' -SAMAccountName 'L4NGH5R1$'

if you continue to get the same error then you need to contact support professionals to fix your network.  It is NOT a scripting issue.

August 17th, 2015 1:09pm

Excellent.  Thank you for the confirmation.
Free Windows Admin Tool Kit Click here and download it now
August 17th, 2015 1:13pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics