Many of the times, you might need to search the entire forest for a particular set of users, on the basis of a security group memberships. Here is a quick attempt to create a CSV file out of it. The script picks each member of the group in the parameter and export their direct group membership. I had a need to run this task on a regular basis and provide a report with regular schedule. I’d put this script to run from schedule task and save the output to a central location.
Hope this helps someone.