Forum Discussion
Andrew van Renen
Aug 01, 2016Brass Contributor
View all external users who have been granted access
(Edit to change title) Hi all A customer asked me how to view a list of all external users who have been granted access to a particualr library of document. Having had a look around, I ca...
SanthoshB1
Aug 03, 2016Bronze Contributor
Andrew van Renen, I am not sure if this will help. But you can use this script to get permission details for selected document library. HTH.
Param(
[Parameter(Position=0, Mandatory=$true, ValueFromPipeline=$true)]
[string] $Username,
[Parameter(Position=1, Mandatory=$true, ValueFromPipeline=$true)]
[string] $Password,
[Parameter(Position=2, Mandatory=$true, ValueFromPipeline=$true)]
[string] $Site,
[Parameter(Position=3, Mandatory=$true, ValueFromPipeline=$true)]
[string] $Library
)
Function Main
{
#Add references to SharePoint client assemblies and authenticate to Office 365 site – required for CSOM
Add-Type -Path ([System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client").location)
Add-Type -Path ([System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.runtime").location)
#Bind to site collection
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($Site)
$creds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username,$(convertto-securestring $Password -asplaintext -force))
$ctx.Credentials = $creds
#Retrieve list
$list = $ctx.Web.Lists.GetByTitle($Library)
$ctx.Load($list)
$ctx.ExecuteQuery()
#Get User's permission in the list
$listRoleAssignments = $List.RoleAssignments
$ctx.Load($listRoleAssignments)
$ctx.ExecuteQuery()
$rec=@()
Foreach($assignment in $listRoleAssignments)
{
$userPermission=$assignment.RoleDefinitionBindings
$memberName=$assignment.Member
$ctx.Load($memberName)
$ctx.Load($userPermission)
$ctx.ExecuteQuery()
$extUserDetails = "" | Select "UserName","Loginname", "Permission"
$userLoginName=$membername.LoginName.ToString()
if($userLoginName -like '*#ext#*')
{
$extUserDetails.Loginname =$userLoginName
$extUserDetails.UserName = $memberName.Title
$extUserDetails.Permission = $UserPermission.name
$rec+= $extUserDetails
}
}
#List out for all External Username with Permission
Write-Host "Total number of External users :" $rec.Count
Write-Host "All External users with Permission details.."
Write-Host "-----------------------------------------------"
$rec
}
Main-Username <Name> -Password <Password>-Site <SiteURL> -Library <document library name>
- Andrew van RenenAug 05, 2016Brass Contributor
Thanks Santhosh
I hadn't looked down the PowerShell route, but that is a handy script. Unfortunately, my client is small company with a single IT person who is a long way from being able to run O365 PowerShell.
According to the documentation, you are supposed to be able to see this information in the Admin panel - it just looks like there is a bug at the moment. Unless other people are able to seet theirs?
- SanthoshB1Aug 05, 2016Bronze Contributor
You can able to see external users for each site collection from old admin center. Navigate to External Sharing > Sites. See below screenshot.
- Alvaro LlobetMay 08, 2017Copper ContributorHi,
Do you know how can we do this with the new modern theme?
I want to know who is sharing files with external people.
The only list I found is on the Admin Center / "invited users" but there isn't any information about which files has access every user.
Many thanks