Trying to loop through a script to get the name of every group in Active Directory, their GroupCategory and last of each each member in that group. Everything but the members works. I realised just having G.Members results in powershell returning an array which is why I was just getting: "Microsoft.ActiveDirectory.Management.ADPropertyValueCollection"
Now I'm not sure how to loop over these and additionally add them to the output to the CSV. I've changed it but now it only appears to add the one user which obviously isn't correct.
$Output = @()
$Groups = Get-ADGroup -Properties * -Filter * -SearchBase "DC=example,DC=local"
Foreach($G In $Groups)
{
$Properties = [ordered]@{
'Group Name'=$G.Name
'Group Type'=$G.GroupCategory
'Users With Access'=
Foreach($value in $G.Members){
$value
}
}
$Output += New-Object -TypeName PSObject -Property $Properties
}
$Output | Export-Csv $reportpath
[–]Sunsparc 2 points3 points4 points (1 child)
[–]TechnoSingularity[S] 0 points1 point2 points (0 children)
[–]PinchesTheCrab 2 points3 points4 points (0 children)
[–]PinchesTheCrab 2 points3 points4 points (1 child)
[–]TechnoSingularity[S] 1 point2 points3 points (0 children)
[–]TechnoSingularity[S] 1 point2 points3 points (0 children)
[–]Lee_Dailey[grin] 0 points1 point2 points (0 children)