Hey all,
I am running into an issue when running a script to all get all the members for each group in AD. The script works fine without -recursive but as soon as I add it I get this error:
Get-ADGroup : A parameter cannot be found that matches parameter name ‘recursive’.
At line:3 char:47
- $Groups = Get-ADGroup -Properties * -Filter * -recursive -SearchBase "OU=Securit …
-
~~~~~~~~~~
- CategoryInfo : InvalidArgument: ( [Get-ADGroup], ParameterBindingException
- FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.ActiveDirectory.Management.Commands.GetADGrou
Import-Module ActiveDirectory
$Groups = Get-ADGroup -Properties * -Filter * -recursive -SearchBase “OU=Security Groups,DC=local,DC=company,DC=org”
$Table = @()
$Record = [ordered]@{
“Group Name” = “”
“Name” = “”
“Username” = “”
}
Foreach ($Group in $Groups)
{
$Arrayofmembers = Get-ADGroupMember -identity $Group | select name,samaccountname
foreach ($Member in $Arrayofmembers)
{
$Record.“Group Name” = $Group
$Record.“Name” = $Member.name
$Record.“UserName” = $Member.samaccountname
$objRecord = New-Object PSObject -property $Record
$Table += $objrecord
}
}
$Table | # export-csv “C:\temp\SecurityGroups.csv” -NoTypeInformation
Out-GridView
Any ideas would be very helpful. Thanks!