1

I am trying to write a script to add a group to an OU, I've stripped out the script and am using the command line to find the error and it looks like -path is incorrect, how do I use powershell to create a group in the specific OU without using -path.

Command

New-ADGroup -name _AB_Read -GroupCategory Security -GroupScope Global -Path OU=TEST,OU=NEW_Groups,DC=Corp1,DC=net

Error

New-ADGroup : Cannot convert 'System.Object[]' to the type 'System.String' required by parameter 'Path'. Specified method is not supported.

At line:1 char:77

  • New-ADGroup -name _PL_Read -GroupCategory Security -GroupScope Global -Path OU=V ...

  • ~~~~

    • CategoryInfo : InvalidArgument: (:) [New-ADGroup], ParameterBindingException

    • FullyQualifiedErrorId : CannotConvertArgument,Microsoft.ActiveDirectory.Management.Commands.NewADGroup

1

Your -Path should look like this -path "OU=TEST,OU=NEW_Groups,DC=Corp1,DC=net". You need " enclosing your path.

Without quotes, it will fail.

So, a new AD group in your desired OU should look like this

New-ADGroup -GroupCategory:"Security" -GroupScope:"Global" -Name:"test1" -Path:"OU=TestOU,DC=Contoso,DC=local" -SamAccountName:"test1" -Server:"dc.contoso.local"
  • Good catch. One note: you should use single quotes when you don't need to evaluate an expression, saves a few cycles compared to double quotes which force evaluation of the expression. – Xalorous Aug 24 '16 at 15:48
  • Cool! Good to know. Every cycle saved is a win in my book. Yeah, my AD powershell knowledge is from using Poweshell history in AD Admin Center. It always shows double quotes so that is what I do. – Art.Vandelay05 Aug 24 '16 at 15:52
  • Thats a good one, worked perfect, and thanks for the tip! – JJJJNR Aug 29 '16 at 10:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.