question

MajerDaniel-5425 avatar image
0 Votes"
MajerDaniel-5425 asked StoyanChalakov commented

Get-ADGroup specific ou

My Code:
$ADGroupList = (Get-ADGroup -Filter * -searchbase "OU=Staedte,DC=dmamgt,DC=local" -Properties *).Name

The error its returning:

Get-ADGroup : Directory object not found At C:\Users\Administrator\Documents\Ordner, Gruppen, Rechte.ps1:31 char:17 + ... roupList = (Get-ADGroup -Filter * -searchbase "OU=Staedte,DC=dmamgt,D ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (:) [Get-ADGroup], ADIdentityNotFoundException + FullyQualifiedErrorId : ActiveDirectoryCmdlet:Microsoft.ActiveDirectory.Management.ADIdentityNotFoundException,Microsoft.ActiveDir ectory.Management.Commands.GetADGroup


Can someone help me? I have no clue why its not working.

windows-server-powershellwindows-active-directory
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

StoyanChalakov avatar image
1 Vote"
StoyanChalakov answered StoyanChalakov edited

Hi Daniel,

I just did a test and it worked fine for me:

38749-image.png
Could it be that you have some Typo in the name of the OU:

"OU=Staedte,DC=dmamgt,DC=local"


Are you sure it is the correct OU CN?
You can use ADSIEDIT or event the Users and Computers mmc to checkl the correct OU name.


(If the reply was helpful please don't forget to upvote or accept as answer, thank you)
Regards,
Stoyan






image.png (59.0 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

MajerDaniel-5425 avatar image
0 Votes"
MajerDaniel-5425 answered MajerDaniel-5425 edited

your right seams like in my script the ou isnt created properly.

there the ou should be created:

New-ADGroup -Name $Folder -GroupScope Global -DisplayName $Folder -Path "OU=Staedte,DC=dmamgt,DC=local" -Description ("Members of this group live on " + $Folder)

Do u see any mistakes?

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

StoyanChalakov avatar image
1 Vote"
StoyanChalakov answered

Hi Daniel,

the command you have posted is creating a new group in the OU with the name "Staedte", but it does not create the OU itself. This means that the OU needs to exist in the firts place. Is this the case? If not, then you can of course create the OU yourself, using:

  New-ADOrganizationalUnit -Name "Staedte" -Path "DC=dmamgmt,DC=local" -ProtectedFromAccidentalDeletion $True

If the OU has already been created, then you can ensure that the Distinguished Name is correct by checking the OU attributes. Here an example with the OU referenced:

38827-image.png

Please let me know in case I can help you further.


(If the reply was helpful please don't forget to upvote or accept as answer, thank you)
Regards,
Stoyan



image.png (15.9 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

MajerDaniel-5425 avatar image
0 Votes"
MajerDaniel-5425 answered StoyanChalakov commented

Thank you for your quick help. You are right it. I thought the ou would be created automaticly because it worked that way in an ohter script.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi Daniel,

glad to help out.

Regards,
Stoyan

0 Votes 0 ·