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, a distinguished professional, boasts an impressive track record as a Microsoft MVP, having achieved this prestigious recognition for the eighth consecutive year since 2015. With an extensive career spanning over 18 years, Adnan has honed his expertise in various domains, notably excelling in SharePoint, Microsoft 365, Microsoft Teams, the .Net Platform, and Microsoft BI. Presently, he holds the esteemed position of Senior Microsoft Consultant at Olive + Goose. Notably, Adnan served as the MCT Regional Lead for the Pakistan Chapter from 2012 to 2017, showcasing his leadership and commitment to fostering growth within the tech community. His journey in the realm of SharePoint spans 14 years, during which he has undertaken diverse projects involving both intranet and internet solutions for both private and government sectors. His impact has transcended geographical boundaries, leaving a mark on projects in the United States and the Gulf region, often collaborating with Fortune 500 companies. Beyond his roles, Adnan is a dedicated educator, sharing his insights and knowledge as a trainer. He also passionately advocates for technology, frequently engaging with the community through speaking engagements in various forums. His multifaceted contributions exemplify his dedication to the tech field and his role in driving its evolution.

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