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.SiteUsers

foreach($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

users Powerscript

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.

Adnan is six time Microsoft MVP (Since 2015) with over 16 years of extensive experience with major expertise on SharePoint, SharePoint based development, Microsoft 365, Microsoft Teams, .Net Platform and Microsoft BI. He is currently working Sr Microsoft Consultant at Olive + Goose. He is MCT Regional Lead for Pakistan Chapter since 2012. He is working on SharePoint for past 12 years and worked on different intranet/intranet solutions for private & govt. sector majorly in United states and Gulf region and have experience of working with multiple Fortune 500 companies. He is a trainer, technology evangelist and also speaks in community forums.

Leave a Reply

13 replies on “SharePoint: Get list of all users using PowerShell script”

  • August 15, 2017 at 7:58 pm

    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.

  • August 17, 2017 at 6:21 am

    Thankfulness to mmy father who shared with me about this weblog, this
    weblog is in fact amazing.

  • August 17, 2017 at 1:37 pm

    Great post! Have nice day ! 🙂 6dise

  • August 19, 2017 at 1:58 am

    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!

  • August 21, 2017 at 12:55 am

    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

  • August 25, 2017 at 8:32 am

    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?

  • August 28, 2017 at 2:12 am

    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.

  • August 30, 2017 at 9:13 pm

    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.

  • September 1, 2017 at 9:41 pm

    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.

  • September 3, 2017 at 11:03 am

    Hi, yup this piece of writing is really fastidious and I have
    learned lot of things from it on the topic of blogging.
    thanks.

  • September 4, 2017 at 2:57 pm

    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!

  • September 5, 2017 at 9:58 pm

    Great post! Have nice day ! 🙂 19njx