SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an auditing / documentation requirement around my SP Environment upon which members of specific groups need to be listed. Now, rather than doing this manually via screen-shots and / or cut and pastes, I'd like to set-up a utility in PS that'll do this for me and can be referred to in the literature.

To this end, I'd like to create a PowerShell script that will take the name of a user group and will output the members of that group into a file.

I've got a few scripts that output user groups and all users per site collection but nothing that allows me to be more surgical in targeting a specific group at a time.

As such, if anyone has a script or a reference to one that I can toy with, I'd appreciate it.

share|improve this question
up vote 2 down vote accepted

First create your script and save it to a file such as ListAllUsersInGroup.ps1

$site = Get-SPSite <UrlToSiteCollection>
$groups = $site.RootWeb.sitegroups

foreach ($group in $groups) 
    if ($ -eq "My Group")
        foreach ($user in $group.users) 
            "  User: " + $


Then you can run the script doing the following letting the output go to file.txt like this

PS > .\ListAllUsersInGroup.ps1 > file.txt

This outputs the result in the same location as your script with the desired information:

enter image description here

share|improve this answer
Perfect. I thought piping would sort it but this works perfectly. – Steven D Andrews Apr 10 '13 at 10:30
@StevenDAndrews Thanks! Glad I could help! – Benny Skogberg Apr 10 '13 at 10:51

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.