Sonntag, 30. Juli 2017

Overview of shared with Externals and shared Anonymous in Office 365

The GDPR highlights the need for protection of personal data held by organizations. To be able to do this Microsoft inverted a lot in new features and functions like the Office 365 Security & Compliance Center or the GDPR Assessment.
One of the backend systems helping to fulfill those regulations is the SharePoint Online Search Service. In the SharePoint Online Search schema, we can find two managed properties focusing on sharing and access from outside of your organization.
ViewableByExternalUsers and ViewableByAnonymousUsers
Both had the same setting: Query, Retrieve, Refine and Sort. So we can use them to create some reports based on search queries.

Personal overview

Office 365 let every user search in his SharePoint Online sites, OneDrive for Business files and also in Emails for content. In this scenario Email is of topic. But using this search function at the landing page of Office 365 a user can create a personal overview of content he shared to externals or anonymous.
To do this a user needs to fill in the following query in the search box at the Office 365 landing page:
ViewableByAnonymousUsers=true


In this example, I search for documents located in SharePoint Online sites or in my personal OneDrive for Business which are shared based on an anonymous guest link.
Using the query ViewableByExternalUsers=true shows me the files shared with external users through a sharing link that requires them to log in before they can view the file.
This gives a user an overview of documents he has shared from his OneDrive for Business with externals or anonymous. Because the URL is generic you can use this link for all your users and every user get his person overview: https://www.office.com/search?auth=2&home=1&q=ViewableByAnonymousUsers%3Dtrue
Also you can use this link to create a tile in the Office 365 App Launcher as described in the article: Add custom tiles to the app launcher
The result may look like this:

Team Site overview

Microsoft integrated a new out the box reporting capability in every Team Site. The article: View usage data for your SharePoint Online site is showing all details you need to know. There is also a new tab called “Shared externally”.
The article says: List of files you have access to that have been shared with users outside your organization through a sharing link that requires them to log in before they can view the file. Files shared with anonymous users or files available to users with guest permissions are not included.
To get a list of files shared anonymous in this Team Site we can again use the query: ViewableByAnonymousUsers=true followed by a path filter like for example: path:https:\\yourTeamSiteName.sharepoint.com.

Using Search Center to get an overview

As an administrator, you can also use the search center to get an overview of anonymous shared content or about data and also SharePoint Online Sites them self, shared to externals. The queries are basically the same and you can extend them with additional keyword queries properties.
For example, search all Office 366 Groups external users can access:
ViewableByExternalUsers=true contentclass:sts_site WebTemplate:GROUP
(Because of security trimming in SharePoint Search the user who runs the query needs access to all Team Sites to gets an complete report.)
Of cause there are also options archiving this using PowerShell for Office 365 Groups or using Reports in the Office 365 Security & Compliance Center. Using the SharePoint Online search gives you the power and flexibility to integrate all managed properties as metadata in you report like for example ViewsLifeTime, LastModifiedTime, CreatedBy or ModifiedBy. In addition you can easily scope your report to only show documents using the IsDocument=true query parameter or to focus to special Site Templates like WebTemplate:GROUP to only show Office 365 Groups Team Sites etc.

Using PowerShell to get the report

Using PowerShell to get results from SharePoint Online Search also offers the option to save the report as an *.csv file. To call SharePoint Online Search API using PowerShell and save the result to an *.csv file you can follow the steps explained by Prasham Sabadra in his article Office 365/Sharepoint Online - PowerShell Script To Call Search API And Get The Result.
This example is based on his description. The report is showing all external shared content and sites in an Office 365 Tenant and is saving the result to C:\Temp\ViewableByExternalUsers.csv
# add references to SharePoint client assemblies and authenticate to Office 365 site - required for CSOM   
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"   
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"   
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Search.dll"
#Specify tenant admin and URL 
$User = "Admin@yourTenant.onmicrosoft.com"   
#Configure Site URL and User 
$SiteURL = "https://yourTenant.sharepoint.com"  
#Password 
$Password ="yourPassword"   
$securePassword = ConvertTo-SecureString -String $Password -AsPlainText –Force  
$Creds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($User,$securePassword)
#client context object and setting the credentials  
$Context = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL) 
$Context.Credentials = $Creds
#Calling Search API - Create the instance of KeywordQuery and set the properties 
$keywordQuery = New-Object Microsoft.SharePoint.Client.Search.Query.KeywordQuery($Context)  
#Sample Query - To get the last year result 
$queryText="ViewableByExternalUsers=true" 
$keywordQuery.QueryText = $queryText 
$keywordQuery.TrimDuplicates=$false 
$keywordQuery.SelectProperties.Add("LastModifiedTime") 
$keywordQuery.SelectProperties.Add("ViewsLifeTime") 
$keywordQuery.SelectProperties.Add("ModifiedBy") 
$keywordQuery.SelectProperties.Add("ViewsLifeTimeUniqueUsers") 
$keywordQuery.SelectProperties.Add("Created") 
$keywordQuery.SelectProperties.Add("CreatedBy") 
$keywordQuery.SortList.Add("ViewsLifeTime","Asc")
#Search API - Create the instance of SearchExecutor and get the result 
$searchExecutor = New-Object Microsoft.SharePoint.Client.Search.Query.SearchExecutor($Context) 
$results = $searchExecutor.ExecuteQuery($keywordQuery) 
$Context.ExecuteQuery() 
#Result Count 
Write-Host $results.Value[0].ResultRows.Count
#CSV file location, to store the result 
$exportlocation = "C:\Temp\ViewableByExternalUsers.csv" 
foreach($result in $results.Value[0].ResultRows) 
$outputline='"'+$result["Title"]+'"'+","+'"'+$result["Path"]+'"'+","+$result["ViewsLifeTime"]+","+$result["ViewsLifeTimeUniqueUsers"]+","+$result["CreatedBy"]+","+$result["Created"]+","+$result["ModifiedBy"]+","+$result["LastModifiedTime"] 
Add-Content $exportlocation $outputline  
}

Keine Kommentare:

Kommentar veröffentlichen