SharePoint In Action

An attempt to share my day-to-day SharePoint experience

Archive for the tag “Export SHarePoint group to a file”

Exporting all SharePoint Group Members Into A File

Hi,
Here is the SharePoint PowerShell script to get all group members for a SharePoint 2010 site and export it to a file:


$mySite = Get-SPSite “your sharepoint site url here”
$txtFile = “c:\groupmembers.txt”
foreach($grp in $mySite.RootWeb.SiteGroups)
{
    "`r`n`r`nGroup Name:” + $grp.Name | Out-File $txtFile -Append
    foreach ($usr in $grp.Users)
    {
          $usr.name + "," + $usr.UserLogin | Out-File $txtFile -Append
    }
} 

Cheers,
Nader Heshmat

Post Navigation