I was having a requirement to get list of all users which have permissions on a sharePoint site and also on any specific list using PowerShell script. You can download script file from Technet Gallery.
Open Windows PowerShell Integrated Scripting Environment, and copy below script.
[System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SharePoint”) > $null
$SiteCollectionURL = “http://sp2013:1111″
$site = new-object Microsoft.SharePoint.SPSite($SiteCollectionURL)
$web = $site.openweb()
$siteUsers = $web.SiteUsersforeach($user in $siteUsers)
{
Write-Host ” ————————————- ”
Write-Host “Site Collection URL:”, $SiteCollectionURL
if($user.IsSiteAdmin -eq $true)
{
Write-Host “ADMIN: “, $user.LoginName
}
else
{
Write-Host “USER: “, $user.LoginName
}
Write-Host ” ————————————- ”
}
$web.Dispose()
$site.Dispose()
The output of above script will be like this
To fetch users listing for any specific list with user roles, you need to do below given modifications in listed code.
$list = $web.Lists[“Custom List”]
$siteCollUsers = $web.SiteUsers
foreach($MyUser in $siteCollUsers)
{
Write-Host ” ————————————- ”
Write-Host “Site Collection URL:”, $SiteCollectionURL
if($list.DoesUserHavePermissions([Microsoft.SharePoint.SPBasePermissions]::ViewListItems,$MyUser) -eq $true)
{
Write-Host “User : “, $MyUser.LoginName
Write-Host “Assigned Permissions : “, $list.GetUserEffectivePermissions($MyUser.LoginName)
}
Write-Host ” ————————————- ”
}
Above script will print the user login names and permissions assigned on SharePoint List.
Leave a Reply
You must be logged in to post a comment.
13 replies on “SharePoint: Get list of all users using PowerShell script”
After examine a couple of of the weblog posts in your web site now, and I really like your manner of blogging. I bookmarked it to my bookmark web site list and will be checking again soon. Pls try my website online as nicely and let me know what you think.
Thankfulness to mmy father who shared with me about this weblog, this
weblog is in fact amazing.
Great post! Have nice day ! 🙂 6dise
Hey, yoou used too write excellent, but the last few
posts have been kinda boring� I miss your great writings.
Past ffew posts arre jjst a little out of track!
come on!
I used to bee able to find good info from your content.
Excellent beat ! I wish to apprentice while you amend your website, hoow can i subscribe for a blog web site?
The account aided me a acceptable deal. I had been a little bit acquainted of this your broadcast provided
bright clear concept
Amazing issues here. I am vedy satisfied to peer your post.
Thank you a lot and I’m taking a look forward to contact you.
Will you please drop me a mail?
I’ve been exploring for a little for any high-quality articles or weblog
posts on this kind oof area . Exploring in Yahoo I at last stumbled upon this website.
Reading this info So i’m happy to convey that I’ve an ncredibly good uncanny
feeling I came upon just what I needed. I so much indisputably
will make sure to don’t pput out of your mind this site and provides it a glance onn a
relentless basis.
Greetings I am so happy I found your site, I really fond you by mistake, while I was browsing
onn Digg for something else, Anyhow I am here now and would just like to say many thanks
for a marvelous post and a all round exciting blog (I also love the theme/design),
I don’t have time to browse it all at the moment buut I have book-marked it and also added in your RSS feeds, so when I
have time I will be bacxk tto read more, Please do keep up the fantastic job.
Link exchange is nothing else but it is only placing the other person’s web site link on your page at proper
place aand other person will also do similar in favor
of you.
Hi, yup this piece of writing is really fastidious and I have
learned lot of things from it on the topic of blogging.
thanks.
I like the valuable information you supply in yoir articles.
I’ll bookmark your weblog and check once more right
here regularly. I am slightly certain I’ll learn a lot oof new stuff roght here!
Best of luck for the following!
Great post! Have nice day ! 🙂 19njx