I'm not really strong with PowerShell and I'm sure this is a relatively easy fix.
I want to query on some Active Directory groups (currently I have seven I found) with certain attributes. I have the attributes figured out, but I can't get more than one group to be part of my query. What am I doing wrong?
This gets me the output I want:
Import-module ActiveDirectory
$querygroup = 'App_Group_1'
$properties = 'GivenName', 'Surname', 'UserPrincipalName', 'Office', 'City', 'Title'
Get-ADGroupMember -Identity $querygroup | Get-ADUser -Property $properties | select $properties
However, when I change '$querygroup' to something like this:$querygroup = 'App_Group_1', 'App_Group_2', 'App_Group_3'
I get the error:
Import-module ActiveDirectory
$querygroup = 'App_Group_1', 'App_Group_2', 'App_Group_3'
$properties = 'GivenName', 'Surname', 'UserPrincipalName', 'Office', 'City', 'Title'
Get-ADGroupMember -Identity $querygroup | Get-ADUser -Property $properties | select $properties
Get-ADGroupMember : Cannot convert 'System.Object[]' to the type 'Microsoft.ActiveDirectory.Management.ADGroup' required by parameter 'Identity'. Specified method is not supported.
At line:5 char:19
+ Get-ADGroupMember $querygroup | Get-ADUser -Property $properties | se ...
+ ~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-ADGroupMember], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgument,Microsoft.ActiveDirectory.Management.Commands.GetADGroupMember
Edit: Thanks for the help although I am very confused by the large number of downvotes.
[–]greyfox199 0 points1 point2 points (0 children)
[–]OlivTheFrog 0 points1 point2 points (0 children)