I am trying to get a list of all AD group members that are a part of at least one of four groups.
I placed the groups into an array and ran a foreach loop on it, piped into Get-ADUser -Filter * and filtered using Where-Object for disabled accounts.
It initially returns 11 results, though these accounts are not members of the groups in the array, and then all further results throw an error
Get-ADUser : The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of the parameters that take pipeline input.At line:1 char:50
CategoryInfo: InvalidArgument: (REDACTED) [Get-ADUser], ParameterBindingException FullyQualifiedErrorId: InputObjectNotBound,Microsoft.ActiveDirectory.Management.Commands.GetADUser
I had tried expanding the properties on Get-ADUser to no avail.
I tried specifying group directly instead of using the array and foreach loop, same error occurred.
These are the commands I ran:
$groups = @('Group1','Group2','Group3','Group4')
foreach ($i in $groups) {Get-ADGroupMember $i | Get-ADUser -Filter * -Properties * | Where-Object {$_.Enabled -eq $False} | Select CN }
Also with the group specified directly without the array and foreach loop
Get-ADGroupMember 'Group1' | Get-ADUser -Filter * -Properties * | Where-Object {$_.Enabled -eq $False} | Select CN
Ryan Dechant is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.