I have an AD group, it has many subgroups and users, for example
Group1 is my AD group. it has many groups and users added to it, i want to export users and groups residing in it to csv file.
Lets say Group1 has below groups and users and i want the output as in the below format.
will the below syntax work for me.
Get-ADGroupMember -Identity "group1" -Recursive | Get-ADUser -Properties Name,Description,UserprincipalName,SamAccountName,office,Department | Select Name,Description,UserprincipalName,SamAccountName,office,Department | Export-CSV -Path C:\temp\output.csv -NoTypeInformation