SharePoint Online: How to Remove Shared Links
Requirement: Remove a share link in SharePoint Online.
How to Remove Share Links in SharePoint Online?
You may have shared specific files or folders with people who don’t have access to the SharePoint Online site through the Share feature (either through the toolbar button or from the context menu), and there may be times when you want to remove a share link (E.g., You want to prevent users from accessing a folder which was shared accidentally). You can remove the shared link to stop users from accessing it. This article will show you how to remove the sharing link from a folder or document so others cannot access it.
Delete a Shared link in SharePoint Online
If a document or folder is shared with specific users, you can remove individual user access from it. If it’s shared with anyone, you have to delete the shared link.
- Browse to your SharePoint Online Document library, where the file or folder you want to remove shared links.
- Right-click on the File/Folder, and Select “Manage Access” from the context menu.
- In the Manage Access popup, To remove users from the shared link, click the drop-down next to users >> Click on the X button next to the user you wish to remove the access from. You’ll be prompted to confirm.
- Similarly, to remove a link shared with everyone, click on the little three dots for “More options”>> Click on the X button next to the link to delete the share link completely.
- Confirm the prompt by clicking on the “Delete link” button.
Once the share link has been removed, anyone who tries to use the link will receive an error message, “This link has been removed. Sorry, access to this document has been removed. Please contact the person who shared it with you.”
As a side note, Users may get this error page when the shared link for the file or folder has expired, too.
Can I remove all shared links in one stretch programmatically?
Unfortunately, No as of today. Although you can remove shared links from item permissions, that leaves the link in an unhealthy state with an error message “This link is broken. Delete it and share the item again.”.
#Remove All "Shared Links" of the Item
$ItemPermission = Get-PnPListItemPermission -List $ListName -Identity $Item.Id
$ItemPermission.Permissions | Where {$_.PrincipalName.StartsWith("SharingLinks")} | ForEach-Object {
$Item.RoleAssignments.GetByPrincipalId($_.PrincipalId).DeleteObject()
Invoke-PnPQuery
}
To remove unique permissions from all files in a document library, use: How to Remove Unique Permissions from All Items in a SharePoint Document Library using PowerShell?
In our organisation we had the option
‘specific people (only the people the user specifies) configured as default file share option on SharePoint online. However, a few weeks ago this option was changed to ‘only people in your organisation’ and we noticed that user can reshare documents with other users from different department. We don’t want that to happen so changed the option back to specific people again. My question is when the option was changed to ‘only people in your organisation’ any shared document links die when the option is changed to specific people?
Is there anyway of using a powershell script to stop the sharing of documents during the time when ‘only people in your organisation’ was set?
Hello, is there a way to reinstate a previously shared link? For work, I have to give a group of people access to a document for two days for them to review. I have to remove their access/delete the link but then they get a chance to review the document again in a few days time. Is there any way to reinstate the same link, as opposed to sharing the document again with a different link? It always causes confusion as people would refer to the previous link and not the new one I send out a few days later. Thank you!
i am a nobody, but i suggest using a link shortener service that supports dynamic link and share that shortened link instead. then on the backend you can update where that dynamic link points to when the actual link changes, or point to company website when you dont want them to have access.