Barceloniak
Barceloniak

Reputation: 13

Retrieve Groups from OU

What is the correct command to execute and retrieve Groups with specification ._RDP (Named - inside OU) on the end?

I Would like to receive all Group names from OU e.g SL_FS_xx_RDP.

That is Parent OU:

OU=Server Admins,OU=Administrative,DC=abcdef,DC=ab

What I've done:

Get-ADOrganizationalUnit -Searchbase 'OU=Server Admins,OU=Administrative,DC=abcdef,DC=ab' -SearchScope OneLevel -Filter * .RDP*

is not working

Upvotes: 0

Views: 73

Answers (1)

Theo
Theo

Reputation: 61068

Still a bit unclear what you want actually.. need retrieve property OU seems redundant because you are already giving it the complete OU in the SearchBase parameter..

However, if i understand you correctly, you would like to get the names of group items within a certain OU that have '_RDP' in their name.

You could do that like so:

Get-ADGroup -Filter {Name -like '*_RDP*'} -Searchbase 'OU=Server Admins,OU=Administrative,DC=abcdef,DC=ab' -SearchScope OneLevel | Select-Object -ExpandProperty Name

or

Get-ADGroup -LDAPFilter "(name=*_RDP*)" -Searchbase 'OU=Server Admins,OU=Administrative,DC=abcdef,DC=ab' -SearchScope OneLevel | Select-Object -ExpandProperty Name

If what you need from these group(s) is more than just the name, remove the Select-Object -ExpandProperty Name part and just do a | ForEach-Object {...}. Also you can use the -Properties switch on the Get-ADGroup cmdlet to feed it with all the properties you are after.

Upvotes: 1

Related Questions