Tuesday, 18 December 2012

How to get SP Users list with Groups by using script

1. First copy the below code and paste in notepad and save the file ext as ps1( Ex: Allusers.ps1)


$site = Get-SPSite http://abc1:8080/
$groups = $site.RootWeb.sitegroups
foreach ($grp in $groups) {$grp.name ; foreach ($user in $grp.users) {" " +$user.name} }
$site.Dispose()


2. Copy in c drive and open SharePoint 2010 Management shell as administrator and run the below command.

PS C:\Users\Administrator> C:\Allusers.ps1 > C:\Userlist.txt


Then the script will run and you will get Site Users list with Groups in Userlist txt file.

For Ref  i am keeping screen shots below.