Forum Discussion
Baron164
Jul 14, 2022Brass Contributor
How can I add group membership information to this csv export?
I am currently exporting a list of user accounts which have uidNumbers. So far so good, but now I need to also include in this export, group information. Specifically the gidNumber for each group eve...
- Jul 19, 2022
$fullReport=@() $AllUsers=Get-ADUser -Filter "uidNumber -ge 0" -Properties Name,givenName,sn,uidNumber,userPrincipalName foreach ($singleuser in $AllUsers){ $Report=[PSCustomObject]@{ Name = $singleuser.Name givenName=$singleuser.GivenName sn=$singleuser.sn uidNumber=$singleuser.uidNumber userPrincipalName=$singleuser.userPrincipalName } $AllGroups=Get-ADPrincipalGroupMembership $singleuser.SamAccountName for ($i = 0; $i -lt $AllGroups.name.count; $i++) { $GroupGid=Get-ADGroup -Properties gidNumber -Identity $AllGroups[$i].SamAccountName $Report | Add-Member -NotePropertyName "Group$i" -NotePropertyValue $GroupGid.gidNumber } $fullReport+=$Report }
Let me know 🙂
farismalaeb
Jul 16, 2022Iron Contributor
Did the proposed solution fix your challenge ? If so please mark the response as best respone