Comments? Questions?

Have a look at my GitHub SharePointOnline-ScriptSamples, where you can find this SharePoint script and many others!

You can find all my repositories at PowershellScripts @ GitHub

 

After you have enabled anonymous links for SharePoint Online tenant, you can set what access level the links can give: edit or only view. The setting is global for the entire tenant.

The script sets tenant sharing to allow anonymous links, and the allowed access levels for files and folders. 

For folders you can choose between View and Edit.

For files you can choose between

Edit - anonymous links will allow to edit documents

View - anonymous links will allow only to view documents

None - users can decide about the access level on per-document basis  (no global setting)

 

 

The script is related to and more described in a Wiki article SharePoint Online Sharing settings with CSOM.

 It requires SharePoint Online SDK.

 

 

How to use?

 

PowerShell
#Paths to SDK 
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\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.Online.SharePoint.Client.Tenant.dll"   
 

 

 

PowerShell
Edit|Remove
#Enter the data 
$AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString 
$username="admin@TENANT.onmicrosoft.com" 
$Url="https://TENANT-admin.sharepoint.com" 
$LinkType="View"  #Edit, View or None 
$FolderLinkType="Edit" # View or Edit