0
votes

I am trying to return a list of members in a certain ou that belong to an active directory group. I am getting the error that:

A parameter cannot be found that matches parameter name 'Searchbase'

Any ideas?

Import-Module ActiveDirectory


Get-ADGroupMember "Test" | -Searchbase "OU=US,DC=domain,DC=net"  | Format-Table Name
1
Try removing the pipe between your command and your parameter. - Anthony Neace
You may need to use -Searchbase with Get-ADGroup and then select the member via Get-ADGroupMember afterwards. Get-ADGroupMember Example 1 has an example of this usage. (Examples are at the bottom of the page) - Anthony Neace
@HyperAnthony is correct since Get-ADGroupMember indeed does not have a -SearchBase parameter. - EBGreen
I tried this but I get another parameter error.Get-AdGroup -Filter * -Searchbase "OU=US,DC=domain,DC=net" | Get-ADGroupMember "Test" | Format-Table Name - user1342164

1 Answers

0
votes

An example comparable to your described situation exists in the documentation for Get-ADGroupMember - Example 1, located towards the bottom of the page. In this example, we are getting the groups members of all domain local groups in the AD LDS instance:

get-adgroup -server localhost:60000 -filter {GroupScope -eq "DomainLocal"} -SearchBase "DC=AppNC" | 
get-adgroupmember -partition "DC=AppNC"

Notice how -Searchbase is a parameter of Get-ADGroup instead of Get-ADGroupMember -- this allows you to get your group once in Get-ADGroup and simply pipe it into Get-ADGroupMember. Piping from variables or other functions is fairly common in powershell, and useful because it keeps your operations separate and (in the case of variables) allows you to reuse results.