SharePoint: Get list of all users using PowerShell script

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
Write-Host “USER: “, $user.LoginName
Write-Host ” ————————————- ”

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 Amin

Adnan is two time SharePoint MVP (Most Valuable Professional) with over 12 years of extensive experience with major expertise on SharePoint Server, Office 365, .Net Platform and Microsoft BI. He is currently working SharePoint Architect at FMT Consultants. He is MCT Regional Lead for Pakistan Chapter since 2012. He is working on SharePoint for past nine years and worked on different intranet/intranet solutions for private & govt. sector majorly in Gulf region, which include OOB and customized solutions. He is a trainer, technology evangelist and also speaks in community forums.

This Post Has 13 Comments

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

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

  3. Shane

    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!

  4. Gaston

    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?

  5. Benito

    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.

  6. Kareem

    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.

  7. Hester

    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.

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

  9. Ina

    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!

Leave a Reply