Site Meter

Saturday, January 21, 2012

Export SharePoint group members using SharePoint 2010 PowerShell

The script for exporting groups membership is following:

$site = Get-SPSite "http://mysites"
$filename = "c:\users.txt"
foreach($group in $site.RootWeb.SiteGroups)
{
    "Group:" + $group.Name | Out-File $filename -Append
    foreach ($user in $group.Users)
    {
        " User:" + $user.UserLogin | Out-File $filename -Append
    }
}
This script will save groups and user from entire site collection to specified file.

0 comments:

Post a Comment

  ©SharePoint Development Tips & Samples - All rights reserved.

By Ivan Vagunin